diff options
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/gdu-device.c | 54 | ||||
-rw-r--r-- | src/gdu-device.h | 45 | ||||
-rw-r--r-- | src/gdu-page-partition-create.c | 2 | ||||
-rw-r--r-- | src/gdu-shell.c | 165 | ||||
-rw-r--r-- | src/gdu-util.c | 212 | ||||
-rw-r--r-- | src/gdu-util.h | 12 | ||||
-rw-r--r-- | src/gdu-volume.c | 7 |
8 files changed, 462 insertions, 39 deletions
diff --git a/configure.ac b/configure.ac index 2d9f6a7..aeaba0f 100644 --- a/configure.ac +++ b/configure.ac @@ -30,11 +30,13 @@ POLKIT_GNOME_REQUIRED=0.7 DBUS_GLIB_REQUIRED=0.75 GTK_REQUIRED=2.6.0 SCROLLKEEPER_REQUIRED=0.3.14 +GNOME_KEYRING_REQUIRED=2.22 PKG_CHECK_MODULES([GNOME_DISK_UTILITY], [gtk+-2.0 >= $GTK_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED - polkit-gnome >= $POLKIT_GNOME_REQUIRED]) + polkit-gnome >= $POLKIT_GNOME_REQUIRED + gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED]) # ************* # Documentation diff --git a/src/gdu-device.c b/src/gdu-device.c index 2ffa773..240a013 100644 --- a/src/gdu-device.c +++ b/src/gdu-device.c @@ -1034,6 +1034,60 @@ gdu_device_op_create_partition_table (GduDevice *device, /* -------------------------------------------------------------------------------- */ +static void +op_unlock_encrypted_cb (DBusGProxy *proxy, char *cleartext_object_path, GError *error, gpointer user_data) +{ + GduDevice *device = GDU_DEVICE (user_data); + if (error != NULL) { + g_warning ("op_unlock_encrypted_cb failed: %s", error->message); + job_set_failed (device, error); + g_error_free (error); + } else { + g_print ("yay cleartext object is at '%s'\n", cleartext_object_path); + g_free (cleartext_object_path); + } + g_object_unref (device); +} + +void +gdu_device_op_unlock_encrypted (GduDevice *device, const char *secret) +{ + char *options[16]; + options[0] = NULL; + org_freedesktop_DeviceKit_Disks_Device_unlock_encrypted_async (device->priv->proxy, + secret, + (const char **) options, + op_unlock_encrypted_cb, + g_object_ref (device)); +} + +/* -------------------------------------------------------------------------------- */ + +static void +op_lock_encrypted_cb (DBusGProxy *proxy, GError *error, gpointer user_data) +{ + GduDevice *device = GDU_DEVICE (user_data); + if (error != NULL) { + g_warning ("op_unlock_encrypted_cb failed: %s", error->message); + job_set_failed (device, error); + g_error_free (error); + } + g_object_unref (device); +} + +void +gdu_device_op_lock_encrypted (GduDevice *device) +{ + char *options[16]; + options[0] = NULL; + org_freedesktop_DeviceKit_Disks_Device_lock_encrypted_async (device->priv->proxy, + (const char **) options, + op_lock_encrypted_cb, + g_object_ref (device)); +} + +/* -------------------------------------------------------------------------------- */ + void gdu_device_op_cancel_job (GduDevice *device) { diff --git a/src/gdu-device.h b/src/gdu-device.h index 2682c81..0e584aa 100644 --- a/src/gdu-device.h +++ b/src/gdu-device.h @@ -126,30 +126,33 @@ const char *gdu_device_drive_get_revision (GduDevice *device); const char *gdu_device_drive_get_serial (GduDevice *device); /* fire and forget ops */ -void gdu_device_op_mkfs (GduDevice *device, - const char *fstype, - const char *fslabel, - const char *fserase); -void gdu_device_op_mount (GduDevice *device); -void gdu_device_op_unmount (GduDevice *device); -void gdu_device_op_delete_partition (GduDevice *device, - const char *secure_erase); -void gdu_device_op_create_partition (GduDevice *device, - guint64 offset, - guint64 size, - const char *type, - const char *label, - char **flags, - const char *fstype, - const char *fslabel, - const char *fserase); -void gdu_device_op_modify_partition (GduDevice *device, - const char *type, - const char *label, - char **flags); +void gdu_device_op_mkfs (GduDevice *device, + const char *fstype, + const char *fslabel, + const char *fserase); +void gdu_device_op_mount (GduDevice *device); +void gdu_device_op_unmount (GduDevice *device); +void gdu_device_op_delete_partition (GduDevice *device, + const char *secure_erase); +void gdu_device_op_create_partition (GduDevice *device, + guint64 offset, + guint64 size, + const char *type, + const char *label, + char **flags, + const char *fstype, + const char *fslabel, + const char *fserase); +void gdu_device_op_modify_partition (GduDevice *device, + const char *type, + const char *label, + char **flags); void gdu_device_op_create_partition_table (GduDevice *device, const char *scheme, const char *secure_erase); +void gdu_device_op_unlock_encrypted (GduDevice *device, + const char *secret); +void gdu_device_op_lock_encrypted (GduDevice *device); diff --git a/src/gdu-page-partition-create.c b/src/gdu-page-partition-create.c index ee8dc46..a4510be 100644 --- a/src/gdu-page-partition-create.c +++ b/src/gdu-page-partition-create.c @@ -535,6 +535,8 @@ has_extended_partition (GduPagePartitionCreate *page, GduPresentable *presentabl } } + g_list_foreach (enclosed_presentables, (GFunc) g_object_unref, NULL); + g_list_free (enclosed_presentables); return ret; } diff --git a/src/gdu-shell.c b/src/gdu-shell.c index e5edabb..1c1abf6 100644 --- a/src/gdu-shell.c +++ b/src/gdu-shell.c @@ -63,6 +63,9 @@ struct _GduShellPrivate PolKitGnomeAction *unmount_action; PolKitGnomeAction *eject_action; + PolKitGnomeAction *unlock_action; + PolKitGnomeAction *lock_action; + GduPresentable *presentable_now_showing; GtkActionGroup *action_group; @@ -148,6 +151,8 @@ gdu_shell_update (GduShell *shell) gboolean can_mount; gboolean can_unmount; gboolean can_eject; + gboolean can_lock; + gboolean can_unlock; GtkWidget *page_widget_currently_showing; job_in_progress = FALSE; @@ -155,6 +160,8 @@ gdu_shell_update (GduShell *shell) can_mount = FALSE; can_unmount = FALSE; can_eject = FALSE; + can_unlock = FALSE; + can_lock = FALSE; /* figure out what pages in the notebook to show + update pages */ device = gdu_presentable_get_device (shell->priv->presentable_now_showing); @@ -167,12 +174,28 @@ gdu_shell_update (GduShell *shell) last_job_failed = TRUE; } - if (GDU_IS_VOLUME (shell->priv->presentable_now_showing) && - strcmp (gdu_device_id_get_usage (device), "filesystem") == 0) { - if (gdu_device_is_mounted (device)) { - can_unmount = TRUE; - } else { - can_mount = TRUE; + if (GDU_IS_VOLUME (shell->priv->presentable_now_showing)) { + + if (strcmp (gdu_device_id_get_usage (device), "filesystem") == 0) { + if (gdu_device_is_mounted (device)) { + can_unmount = TRUE; + } else { + can_mount = TRUE; + } + } else if (strcmp (gdu_device_id_get_usage (device), "crypto") == 0) { + GList *enclosed_presentables; + enclosed_presentables = gdu_pool_get_enclosed_presentables ( + shell->priv->pool, + shell->priv->presentable_now_showing); + if (enclosed_presentables != NULL) { + can_lock = TRUE; + } else { + can_unlock = TRUE; + } + g_list_foreach (enclosed_presentables, (GFunc) g_object_unref, NULL); + g_list_free (enclosed_presentables); + + } } @@ -237,14 +260,34 @@ gdu_shell_update (GduShell *shell) polkit_gnome_action_set_sensitive (shell->priv->mount_action, can_mount); polkit_gnome_action_set_sensitive (shell->priv->unmount_action, can_unmount); polkit_gnome_action_set_sensitive (shell->priv->eject_action, can_eject); + polkit_gnome_action_set_sensitive (shell->priv->lock_action, can_lock); + polkit_gnome_action_set_sensitive (shell->priv->unlock_action, can_unlock); + +#if 0 + /* TODO */ + if (can_lock || can_unlock) { + g_warning ("a"); + polkit_gnome_action_set_visible (shell->priv->mount_action, FALSE); + polkit_gnome_action_set_visible (shell->priv->unmount_action, FALSE); + polkit_gnome_action_set_visible (shell->priv->eject_action, FALSE); + polkit_gnome_action_set_visible (shell->priv->lock_action, TRUE); + polkit_gnome_action_set_visible (shell->priv->unlock_action, TRUE); + } else { + g_warning ("b"); + polkit_gnome_action_set_visible (shell->priv->mount_action, TRUE); + polkit_gnome_action_set_visible (shell->priv->unmount_action, TRUE); + polkit_gnome_action_set_visible (shell->priv->eject_action, TRUE); + polkit_gnome_action_set_visible (shell->priv->lock_action, FALSE); + polkit_gnome_action_set_visible (shell->priv->unlock_action, FALSE); + } +#endif } static void presentable_changed (GduPresentable *presentable, gpointer user_data) { GduShell *shell = user_data; - if (presentable == shell->priv->presentable_now_showing) - gdu_shell_update (shell); + gdu_shell_update (shell); } static void @@ -288,6 +331,13 @@ device_tree_changed (GtkTreeSelection *selection, gpointer user_data) } static void +presentable_added (GduPool *pool, GduPresentable *presentable, gpointer user_data) +{ + GduShell *shell = user_data; + gdu_shell_update (shell); +} + +static void presentable_removed (GduPool *pool, GduPresentable *presentable, gpointer user_data) { GduShell *shell = user_data; @@ -307,6 +357,7 @@ presentable_removed (GduPool *pool, GduPresentable *presentable, gpointer user_d gdu_tree_select_first_presentable (GTK_TREE_VIEW (shell->priv->treeview)); } } + gdu_shell_update (shell); } @@ -342,6 +393,42 @@ eject_action_callback (GtkAction *action, gpointer user_data) g_warning ("todo: eject"); } +static void +unlock_action_callback (GtkAction *action, gpointer user_data) +{ + GduShell *shell = user_data; + GduDevice *device; + + device = gdu_presentable_get_device (shell->priv->presentable_now_showing); + if (device != NULL) { + char *secret; + + secret = gdu_util_dialog_ask_for_secret_with_keyring (shell->priv->app_window, + shell->priv->presentable_now_showing); + if (secret != NULL) { + gdu_device_op_unlock_encrypted (device, secret); + g_object_unref (device); + + /* scrub the password */ + memset (secret, '\0', strlen (secret)); + g_free (secret); + } + } +} + +static void +lock_action_callback (GtkAction *action, gpointer user_data) +{ + GduShell *shell = user_data; + GduDevice *device; + + device = gdu_presentable_get_device (shell->priv->presentable_now_showing); + if (device != NULL) { + gdu_device_op_lock_encrypted (device); + g_object_unref (device); + } +} + static void help_contents_action_callback (GtkAction *action, gpointer user_data) @@ -386,6 +473,9 @@ static const gchar *ui = " <menuitem action='mount'/>" " <menuitem action='unmount'/>" " <menuitem action='eject'/>" + " <separator/>" + " <menuitem action='unlock'/>" + " <menuitem action='lock'/>" " </menu>" " <menu action='help'>" " <menuitem action='contents'/>" @@ -396,6 +486,9 @@ static const gchar *ui = " <toolitem action='mount'/>" " <toolitem action='unmount'/>" " <toolitem action='eject'/>" + " <separator/>" + " <toolitem action='unlock'/>" + " <toolitem action='lock'/>" " </toolbar>" "</ui>"; @@ -429,9 +522,9 @@ create_ui_manager (GduShell *shell) /* -------------------------------------------------------------------------------- */ shell->priv->mount_action = polkit_gnome_action_new_default ("mount", - shell->priv->pk_mount_action, - _("_Mount"), - _("Mount")); + shell->priv->pk_mount_action, + _("_Mount"), + _("Make the file system on the device available")); g_object_set (shell->priv->mount_action, "auth-label", _("_Mount..."), "yes-icon-name", "gdu-mount", @@ -445,9 +538,9 @@ create_ui_manager (GduShell *shell) /* -------------------------------------------------------------------------------- */ shell->priv->unmount_action = polkit_gnome_action_new_default ("unmount", - NULL, /* TODO */ - _("_Unmount"), - _("Unmount")); + NULL, /* TODO */ + _("_Unmount"), + _("Make the file system on the device unavailable")); g_object_set (shell->priv->unmount_action, "auth-label", _("_Unmount..."), "yes-icon-name", "gdu-unmount", @@ -461,9 +554,9 @@ create_ui_manager (GduShell *shell) /* -------------------------------------------------------------------------------- */ shell->priv->eject_action = polkit_gnome_action_new_default ("eject", - NULL, /* TODO */ - _("_Eject"), - _("Eject")); + NULL, /* TODO */ + _("_Eject"), + _("Eject media from the device")); g_object_set (shell->priv->eject_action, "auth-label", _("_Eject..."), "yes-icon-name", "gdu-eject", @@ -476,6 +569,43 @@ create_ui_manager (GduShell *shell) /* -------------------------------------------------------------------------------- */ + shell->priv->unlock_action = polkit_gnome_action_new_default ("unlock", + /* TODO: for now use the mount pk action */ + shell->priv->pk_mount_action, + _("_Unlock"), + _("Unlock the encrypted device, making the data available in cleartext")); + /* TODO: the lock-secure and lock-insecure icons are from Epiphany. + * Probably need to ship our own copy. + */ + + g_object_set (shell->priv->unlock_action, + "auth-label", _("_Unlock..."), + "yes-icon-name", "stock_lock-open", + "no-icon-name", "stock_lock-open", + "auth-icon-name", "stock_lock-open", + "self-blocked-icon-name", "stock_lock-open", + NULL); + g_signal_connect (shell->priv->unlock_action, "activate", G_CALLBACK (unlock_action_callback), shell); + gtk_action_group_add_action (shell->priv->action_group, GTK_ACTION (shell->priv->unlock_action)); + + /* -------------------------------------------------------------------------------- */ + + shell->priv->lock_action = polkit_gnome_action_new_default ("lock", + NULL, /* TODO */ + _("_Lock"), + _("Lock the encrypted device, making the cleartext data unavailable")); + g_object_set (shell->priv->lock_action, + "auth-label", _("_Lock..."), + "yes-icon-name", "stock_lock", + "no-icon-name", "stock_lock", + "auth-icon-name", "stock_lock", + "self-blocked-icon-name", "stock_lock", + NULL); + g_signal_connect (shell->priv->lock_action, "activate", G_CALLBACK (lock_action_callback), shell); + gtk_action_group_add_action (shell->priv->action_group, GTK_ACTION (shell->priv->lock_action)); + + /* -------------------------------------------------------------------------------- */ + ui_manager = gtk_ui_manager_new (); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->action_group, 0); @@ -586,6 +716,7 @@ create_window (GduShell *shell) /* when starting up, set focus on tree view */ gtk_widget_grab_focus (shell->priv->treeview); + g_signal_connect (shell->priv->pool, "presentable-added", (GCallback) presentable_added, shell); g_signal_connect (shell->priv->pool, "presentable-removed", (GCallback) presentable_removed, shell); g_signal_connect (shell->priv->app_window, "delete-event", gtk_main_quit, NULL); diff --git a/src/gdu-util.c b/src/gdu-util.c index 6d7a811..7d0f017 100644 --- a/src/gdu-util.c +++ b/src/gdu-util.c @@ -24,6 +24,7 @@ #include <string.h> #include <glib/gi18n.h> #include <polkit-gnome/polkit-gnome.h> +#include <gnome-keyring.h> #include "gdu-util.h" @@ -956,6 +957,7 @@ gdu_util_secure_erase_combo_box_set_desc_label (GtkWidget *combo_box, GtkWidget gdu_util_secure_erase_combo_box_update_desc_label (combo_box); } +/* ---------------------------------------------------------------------------------------------------- */ char * gdu_util_get_default_part_type_for_scheme_and_fstype (const char *scheme, const char *fstype, guint64 size) @@ -987,6 +989,8 @@ gdu_util_get_default_part_type_for_scheme_and_fstype (const char *scheme, const return g_strdup (type); } +/* ---------------------------------------------------------------------------------------------------- */ + /** * gdu_util_find_toplevel_presentable: * @presentable: a #GduPresentable. @@ -1012,3 +1016,211 @@ gdu_util_find_toplevel_presentable (GduPresentable *presentable) return g_object_ref (parent); } + +/* ---------------------------------------------------------------------------------------------------- */ + +static GnomeKeyringPasswordSchema encrypted_device_password_schema = { + GNOME_KEYRING_ITEM_GENERIC_SECRET, + { + { "encrypted-device-uuid", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, + { NULL, 0 } + } +}; + +char * +gdu_util_dialog_ask_for_secret_with_keyring (GtkWidget *parent_window, + GduPresentable *presentable) +{ + char *secret; + char *password; + const char *usage; + const char *uuid; + GduDevice *device; + gboolean save_in_keyring; + gboolean save_in_keyring_session; + + secret = NULL; + + device = gdu_presentable_get_device (presentable); + if (device == NULL) { + g_warning ("%s: device is NULL", __FUNCTION__); + goto out; + } + + usage = gdu_device_id_get_usage (device); + uuid = gdu_device_id_get_uuid (device); + + if (strcmp (usage, "crypto") != 0) { + g_warning ("%s: device is not a crypto device", __FUNCTION__); + goto out; + } + + if (uuid == NULL || strlen (uuid) == 0) { + g_warning ("%s: device has no UUID", __FUNCTION__); + goto out; + } + + if (gnome_keyring_find_password_sync (&encrypted_device_password_schema, + &password, + "encrypted-device-uuid", uuid, + NULL) == GNOME_KEYRING_RESULT_OK) { + /* By contract, the caller is responsible for scrubbing the password + * so dupping the string into pageable memory "fine". Or not? + */ + secret = g_strdup (password); + gnome_keyring_free_password (password); + goto out; + } + + secret = gdu_util_dialog_ask_for_secret (parent_window, + presentable, + &save_in_keyring, + &save_in_keyring_session); + + if (secret != NULL && (save_in_keyring || save_in_keyring_session)) { + const char *keyring; + + keyring = NULL; + if (save_in_keyring_session) + keyring = GNOME_KEYRING_SESSION; + + if (gnome_keyring_store_password_sync (&encrypted_device_password_schema, + keyring, + _("Encrypted Disk Passphrase"), + secret, + "encrypted-device-uuid", uuid, + NULL) != GNOME_KEYRING_RESULT_OK) { + g_warning ("%s: couldn't store passphrase in keyring", __FUNCTION__); + } + } + +out: + if (device != NULL) + g_object_unref (device); + return secret; +} + +char * +gdu_util_dialog_ask_for_secret (GtkWidget *parent_window, + GduPresentable *presentable, + gboolean *save_in_keyring, + gboolean *save_in_keyring_session) +{ + int response; + char *secret; + GtkWidget *dialog; + GtkWidget *image; + GtkWidget *hbox; + GtkWidget *main_vbox; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *table_alignment; + GtkWidget *table; + GtkWidget *password_entry; + GtkWidget *never_radio_button; + GtkWidget *session_radio_button; + GtkWidget *always_radio_button; + + g_return_val_if_fail (parent_window == NULL || GTK_IS_WINDOW (parent_window), NULL); + g_return_val_if_fail (GDU_IS_PRESENTABLE (presentable), NULL); + + secret = NULL; + + dialog = gtk_dialog_new_with_buttons (_("Unlock Encrypted Device"), + GTK_WINDOW (parent_window), + GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_NO_SEPARATOR, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + NULL); + + gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Unlock"), 0); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), 0); + + gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); /* 2 * 5 + 2 = 12 */ + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 6); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION); + + hbox = gtk_hbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0); + + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); + gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); + + main_vbox = gtk_vbox_new (FALSE, 10); + gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0); + + /* main message */ + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), + "<b><big>To unlock the data, enter the passphrase for the device.</big></b>"); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (label), FALSE, FALSE, 0); + + /* secondary message */ + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), _("Data on this device is stored in an encrypted form " + "protected by a passphrase.")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (label), FALSE, FALSE, 0); + + /* password entry */ + vbox = gtk_vbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); + + table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); + gtk_box_pack_start (GTK_BOX (vbox), table_alignment, FALSE, FALSE, 0); + table = gtk_table_new (1, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_table_set_row_spacings (GTK_TABLE (table), 6); + gtk_container_add (GTK_CONTAINER (table_alignment), table); + password_entry = gtk_entry_new (); + gtk_entry_set_visibility (GTK_ENTRY (password_entry), FALSE); + gtk_entry_set_activates_default (GTK_ENTRY (password_entry), TRUE); + + label = gtk_label_new_with_mnemonic (_("_Passphrase:")); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, 0, 0 + 1, + GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach_defaults (GTK_TABLE (table), password_entry, 1, 2, 0, 1 + 1); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), password_entry); + + never_radio_button = gtk_radio_button_new_with_mnemonic ( + NULL, + _("_Forget passphrase immediately")); + session_radio_button = gtk_radio_button_new_with_mnemonic_from_widget ( + GTK_RADIO_BUTTON (never_radio_button), + _("Remember passphrase until you _log out")); + always_radio_button = gtk_radio_button_new_with_mnemonic_from_widget ( + GTK_RADIO_BUTTON (never_radio_button), + _("_Remember forever")); + + gtk_box_pack_start (GTK_BOX (vbox), never_radio_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), session_radio_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), always_radio_button, FALSE, FALSE, 0); + + gtk_widget_show_all (dialog); + response = gtk_dialog_run (GTK_DIALOG (dialog)); + if (response != 0) + goto out; + + secret = g_strdup (gtk_entry_get_text (GTK_ENTRY (password_entry))); + if (save_in_keyring != NULL) + *save_in_keyring = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (always_radio_button)); + if (save_in_keyring_session != NULL) + *save_in_keyring_session = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (session_radio_button)); + +out: + if (dialog != NULL) + gtk_widget_destroy (dialog); + return secret; +} + diff --git a/src/gdu-util.h b/src/gdu-util.h index fead13c..4f0cc33 100644 --- a/src/gdu-util.h +++ b/src/gdu-util.h @@ -85,4 +85,16 @@ char *gdu_util_part_table_type_combo_box_get_selected (GtkWidget *combo_ GduPresentable *gdu_util_find_toplevel_presentable (GduPresentable *presentable); +/* ---------------------------------------------------------------------------------------------------- */ + +char *gdu_util_dialog_ask_for_secret (GtkWidget *parent_window, + GduPresentable *presentable, + gboolean *save_in_keyring, + gboolean *save_in_keyring_session); + +char *gdu_util_dialog_ask_for_secret_with_keyring (GtkWidget *parent_window, + GduPresentable *presentable); + + + #endif /* GDU_UTIL_H */ diff --git a/src/gdu-volume.c b/src/gdu-volume.c index e47ee12..e99fab5 100644 --- a/src/gdu-volume.c +++ b/src/gdu-volume.c @@ -138,6 +138,7 @@ gdu_volume_get_name (GduPresentable *presentable) { GduVolume *volume = GDU_VOLUME (presentable); const char *label; + const char *usage; char *result; gboolean is_extended_partition; char *strsize; @@ -156,6 +157,8 @@ gdu_volume_get_name (GduPresentable *presentable) is_extended_partition = TRUE; } + usage = gdu_device_id_get_usage (volume->priv->device); + if (is_extended_partition) { size = gdu_device_partition_get_size (volume->priv->device); strsize = gdu_util_get_size_for_display (size, FALSE); @@ -163,6 +166,10 @@ gdu_volume_get_name (GduPresentable *presentable) g_free (strsize); } else if (label != NULL && strlen (label) > 0) { result = g_strdup (label); + } else if (usage != NULL && strcmp (usage, "crypto") == 0) { + strsize = gdu_util_get_size_for_display (size, FALSE); + result = g_strdup_printf (_("%s Encrypted"), strsize); + g_free (strsize); } else { strsize = gdu_util_get_size_for_display (size, FALSE); result = g_strdup_printf (_("%s Partition"), strsize); |