Index: thunar/thunar-shortcuts-view.c =================================================================== --- thunar/thunar-shortcuts-view.c (revision 26668) +++ thunar/thunar-shortcuts-view.c (working copy) @@ -828,14 +828,22 @@ if (G_UNLIKELY (volume != NULL)) { /* append the "Mount Volume" menu action */ - item = gtk_image_menu_item_new_with_mnemonic (_("_Mount Volume")); - gtk_widget_set_sensitive (item, !thunar_vfs_volume_is_mounted (volume)); + if (G_UNLIKELY(thunar_vfs_volume_is_crypto(volume))) + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Setup crypto layer")); + gtk_widget_set_sensitive (item, !thunar_vfs_volume_is_crypto_setup (volume)); + } + else + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Mount Volume")); + gtk_widget_set_sensitive (item, !thunar_vfs_volume_is_mounted (volume)); + } g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_mount), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); /* check if the volume is ejectable */ - if (thunar_vfs_volume_is_ejectable (volume)) + if (thunar_vfs_volume_is_ejectable (volume) && !thunar_vfs_volume_is_crypto(volume)) { /* append the "Eject Volume" menu action */ item = gtk_image_menu_item_new_with_mnemonic (_("E_ject Volume")); @@ -846,8 +854,16 @@ else { /* append the "Unmount Volume" menu item */ - item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume")); - gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume)); + if (G_UNLIKELY(thunar_vfs_volume_is_crypto(volume))) + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Teardown crypto layer")); + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_crypto_setup (volume)); + } + else + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume")); + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume)); + } g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_unmount), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); Index: thunar/thunar-tree-view.c =================================================================== --- thunar/thunar-tree-view.c (revision 26668) +++ thunar/thunar-tree-view.c (working copy) @@ -1035,14 +1035,22 @@ if (G_UNLIKELY (volume != NULL)) { /* append the "Mount Volume" menu action */ - item = gtk_image_menu_item_new_with_mnemonic (_("_Mount Volume")); - gtk_widget_set_sensitive (item, !thunar_vfs_volume_is_mounted (volume)); + if (G_UNLIKELY(thunar_vfs_volume_is_crypto(volume))) + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Setup crypto layer")); + gtk_widget_set_sensitive (item, !thunar_vfs_volume_is_crypto_setup (volume)); + } + else + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Mount Volume")); + gtk_widget_set_sensitive (item, !thunar_vfs_volume_is_mounted (volume)); + } g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_mount), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); /* check if the volume is ejectable */ - if (thunar_vfs_volume_is_ejectable (volume)) + if (thunar_vfs_volume_is_ejectable (volume) && !thunar_vfs_volume_is_crypto(volume)) { /* append the "Eject Volume" menu action */ item = gtk_image_menu_item_new_with_mnemonic (_("E_ject Volume")); @@ -1053,8 +1061,16 @@ else { /* append the "Unmount Volume" menu item */ - item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume")); - gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume)); + if (G_UNLIKELY(thunar_vfs_volume_is_crypto(volume))) + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Teardown crypto layer")); + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_crypto_setup (volume)); + } + else + { + item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount Volume")); + gtk_widget_set_sensitive (item, thunar_vfs_volume_is_mounted (volume)); + } g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_unmount), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); Index: thunar-vfs/thunar-vfs-volume-hal.c =================================================================== --- thunar-vfs/thunar-vfs-volume-hal.c (revision 26668) +++ thunar-vfs/thunar-vfs-volume-hal.c (working copy) @@ -54,6 +54,8 @@ static ThunarVfsVolumeStatus thunar_vfs_volume_hal_get_status (ThunarVfsVolume *volume); static ThunarVfsPath *thunar_vfs_volume_hal_get_mount_point (ThunarVfsVolume *volume); static gboolean thunar_vfs_volume_hal_is_ejectable (ThunarVfsVolume *volume); +static gboolean thunar_vfs_volume_hal_is_crypto (ThunarVfsVolume *volume); +static gboolean thunar_vfs_volume_hal_is_crypto_setup (ThunarVfsVolume *volume); static const gchar *thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume, GtkIconTheme *icon_theme); static gboolean thunar_vfs_volume_hal_eject (ThunarVfsVolume *volume, @@ -72,8 +74,6 @@ LibHalVolume *hv, LibHalDrive *hd); - - struct _ThunarVfsVolumeHalClass { ThunarVfsVolumeClass __parent__; @@ -84,7 +84,7 @@ ThunarVfsVolume __parent__; gchar *udi; - + gchar *plain_udi; gchar *device_file; gchar *device_label; @@ -142,6 +142,8 @@ thunarvfs_volume_class->get_status = thunar_vfs_volume_hal_get_status; thunarvfs_volume_class->get_mount_point = thunar_vfs_volume_hal_get_mount_point; thunarvfs_volume_class->is_ejectable = thunar_vfs_volume_hal_is_ejectable; + thunarvfs_volume_class->is_crypto = thunar_vfs_volume_hal_is_crypto; + thunarvfs_volume_class->is_crypto_setup = thunar_vfs_volume_hal_is_crypto_setup; thunarvfs_volume_class->lookup_icon_name = thunar_vfs_volume_hal_lookup_icon_name; thunarvfs_volume_class->eject = thunar_vfs_volume_hal_eject; thunarvfs_volume_class->mount = thunar_vfs_volume_hal_mount; @@ -216,7 +218,24 @@ } +static gboolean +thunar_vfs_volume_hal_is_crypto (ThunarVfsVolume *volume) +{ + return THUNAR_VFS_VOLUME_HAL (volume)->kind == THUNAR_VFS_VOLUME_KIND_CRYPTO; +} +static gboolean +thunar_vfs_volume_hal_is_crypto_setup (ThunarVfsVolume *volume) +{ + if (THUNAR_VFS_VOLUME_HAL (volume)->kind != THUNAR_VFS_VOLUME_KIND_CRYPTO) + return FALSE; + + return THUNAR_VFS_VOLUME_HAL (volume)->plain_udi != NULL; +} + + + + static const gchar* thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume, GtkIconTheme *icon_theme) @@ -282,25 +301,28 @@ if (G_LIKELY (result)) { /* try to figure out where the device was mounted */ - path = thunar_vfs_volume_hal_find_active_mount_point (volume_hal); - if (G_LIKELY (path != NULL)) + if (volume_hal->kind != THUNAR_VFS_VOLUME_KIND_CRYPTO) { - /* we must have been mounted successfully */ - volume_hal->status |= THUNAR_VFS_VOLUME_STATUS_MOUNTED | THUNAR_VFS_VOLUME_STATUS_PRESENT; + path = thunar_vfs_volume_hal_find_active_mount_point (volume_hal); + if (G_LIKELY (path != NULL)) + { + /* we must have been mounted successfully */ + volume_hal->status |= THUNAR_VFS_VOLUME_STATUS_MOUNTED | THUNAR_VFS_VOLUME_STATUS_PRESENT; - /* replace the existing mount point */ - thunar_vfs_path_unref (volume_hal->mount_point); - volume_hal->mount_point = path; + /* replace the existing mount point */ + thunar_vfs_path_unref (volume_hal->mount_point); + volume_hal->mount_point = path; - /* tell everybody that we have a new state */ - thunar_vfs_volume_changed (THUNAR_VFS_VOLUME (volume_hal)); - } - else - { - /* something went wrong, for sure */ - g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Failed to determine the mount point for %s"), volume_hal->device_file); - result = FALSE; - } + /* tell everybody that we have a new state */ + thunar_vfs_volume_changed (THUNAR_VFS_VOLUME (volume_hal)); + } + else + { + /* something went wrong, for sure */ + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Failed to determine the mount point for %s"), volume_hal->device_file); + result = FALSE; + } + } } return result; @@ -326,7 +348,7 @@ if (G_LIKELY (result)) { /* reset the status */ - volume_hal->status &= ~THUNAR_VFS_VOLUME_STATUS_MOUNTED; + volume_hal->status &= ~(THUNAR_VFS_VOLUME_STATUS_MOUNTED); /* emit "changed" on the volume */ thunar_vfs_volume_changed (THUNAR_VFS_VOLUME (volume_hal)); @@ -359,7 +381,6 @@ g_slist_foreach (mount_points, (GFunc) exo_mount_point_free, NULL); g_slist_free (mount_points); } - return mount_point; } @@ -541,6 +562,12 @@ if(hv != NULL && libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM) volume_hal->status |= THUNAR_VFS_VOLUME_STATUS_MOUNTABLE; + /* force the type to CRYPTO if necessary */ + if (libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_CRYPTO) + { + volume_hal->kind = THUNAR_VFS_VOLUME_KIND_CRYPTO; + volume_hal->plain_udi = libhal_volume_crypto_get_clear_volume_udi (context, hv); + } /* check if the drive requires eject */ volume_hal->requires_eject = libhal_drive_requires_eject (hd); @@ -686,7 +713,6 @@ } - static void thunar_vfs_volume_manager_hal_class_init (ThunarVfsVolumeManagerHalClass *klass) { @@ -982,7 +1008,13 @@ /* unable to determine the drive, volume gone? */ thunar_vfs_volume_manager_hal_device_removed (manager_hal->context, udi); } - + + /* if it's a crypto device, update the plain udi */ + if (G_UNLIKELY(libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_CRYPTO)) + { + g_free(volume_hal->plain_udi); + volume_hal->plain_udi = libhal_volume_crypto_get_clear_volume_udi (manager_hal->context, hv); + } /* release the volume */ libhal_volume_free (hv); } @@ -1019,7 +1051,8 @@ if (G_LIKELY (hv != NULL)) { /* check if we have a mountable file system here */ - if (libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM) + if (libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM + || libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_CRYPTO) { /* determine the UDI of the drive to which this volume belongs */ drive_udi = libhal_volume_get_storage_device_udi (hv); Index: thunar-vfs/thunar-vfs-volume.c =================================================================== --- thunar-vfs/thunar-vfs-volume.c (revision 26668) +++ thunar-vfs/thunar-vfs-volume.c (working copy) @@ -318,8 +318,46 @@ } +/** + * thunar_vfs_volume_is_crypto: + * @volume : a #ThunarVfsVolume instance. + * + * Determines whether @volume is a crypto container + * + * Return value: whether @volume can is a crypto container. + **/ +gboolean +thunar_vfs_volume_is_crypto (ThunarVfsVolume *volume) +{ + g_return_val_if_fail (THUNAR_VFS_IS_VOLUME (volume), FALSE); + if (*THUNAR_VFS_VOLUME_GET_CLASS (volume)->is_crypto) + return (*THUNAR_VFS_VOLUME_GET_CLASS (volume)->is_crypto) (volume); + else + return FALSE; +} + /** + * thunar_vfs_volume_is_crypto: + * @volume : a #ThunarVfsVolume instance. + * + * Determines whether @volume is a crypto container + * + * Return value: whether @volume can is a crypto container. + **/ +gboolean +thunar_vfs_volume_is_crypto_setup (ThunarVfsVolume *volume) +{ + g_return_val_if_fail (THUNAR_VFS_IS_VOLUME (volume), FALSE); + if (*THUNAR_VFS_VOLUME_GET_CLASS (volume)->is_crypto_setup) + return (*THUNAR_VFS_VOLUME_GET_CLASS (volume)->is_crypto_setup) (volume); + else + return FALSE; +} + + + +/** * thunar_vfs_volume_is_removable: * @volume : a #ThunarVfsVolume instance. * @@ -354,6 +392,7 @@ case THUNAR_VFS_VOLUME_KIND_AUDIO_CD: case THUNAR_VFS_VOLUME_KIND_MEMORY_CARD: case THUNAR_VFS_VOLUME_KIND_REMOVABLE_DISK: + case THUNAR_VFS_VOLUME_KIND_CRYPTO: return TRUE; default: Index: thunar-vfs/thunar-vfs-volume.h =================================================================== --- thunar-vfs/thunar-vfs-volume.h (revision 26668) +++ thunar-vfs/thunar-vfs-volume.h (working copy) @@ -56,6 +56,7 @@ * @THUNAR_VFS_VOLUME_KIND_AUDIO_CD : Audio CDs. * @THUNAR_VFS_VOLUME_KIND_MEMORY_CARD : Memory cards. * @THUNAR_VFS_VOLUME_KIND_REMOVABLE_DISK : Other removable disks. + * @THUNAR_VFS_VOLUME_KIND_CRYPTO : Crypto fs container. * * Describes the type of a VFS volume. **/ @@ -78,6 +79,7 @@ THUNAR_VFS_VOLUME_KIND_AUDIO_CD, THUNAR_VFS_VOLUME_KIND_MEMORY_CARD, THUNAR_VFS_VOLUME_KIND_REMOVABLE_DISK, + THUNAR_VFS_VOLUME_KIND_CRYPTO, } ThunarVfsVolumeKind; /** @@ -90,9 +92,9 @@ **/ typedef enum /*< flags >*/ { - THUNAR_VFS_VOLUME_STATUS_MOUNTED = 1 << 0, - THUNAR_VFS_VOLUME_STATUS_PRESENT = 1 << 1, - THUNAR_VFS_VOLUME_STATUS_MOUNTABLE = 1 << 2, + THUNAR_VFS_VOLUME_STATUS_MOUNTED = 1 << 0, + THUNAR_VFS_VOLUME_STATUS_PRESENT = 1 << 1, + THUNAR_VFS_VOLUME_STATUS_MOUNTABLE = 1 << 2, } ThunarVfsVolumeStatus; GType thunar_vfs_volume_get_type (void) G_GNUC_CONST; @@ -109,6 +111,9 @@ gboolean thunar_vfs_volume_is_ejectable (ThunarVfsVolume *volume); gboolean thunar_vfs_volume_is_removable (ThunarVfsVolume *volume); +gboolean thunar_vfs_volume_is_crypto (ThunarVfsVolume *volume); +gboolean thunar_vfs_volume_is_crypto_setup (ThunarVfsVolume *volume); + const gchar *thunar_vfs_volume_lookup_icon_name (ThunarVfsVolume *volume, GtkIconTheme *icon_theme); Index: thunar-vfs/thunar-vfs-volume-private.h =================================================================== --- thunar-vfs/thunar-vfs-volume-private.h (revision 26668) +++ thunar-vfs/thunar-vfs-volume-private.h (working copy) @@ -56,6 +56,8 @@ void (*mounted) (ThunarVfsVolume *volume); void (*pre_unmount) (ThunarVfsVolume *volume); void (*unmounted) (ThunarVfsVolume *volume); + gboolean (*is_crypto) (ThunarVfsVolume *volume); + gboolean (*is_crypto_setup) (ThunarVfsVolume *volume); }; struct _ThunarVfsVolume