~ubuntu-branches/ubuntu/maverick/gnome-mount/maverick

« back to all changes in this revision

Viewing changes to src/gnome-mount.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 18:02:20 UTC
  • mfrom: (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20081006180220-i3ldd964azzpnoo1
Tags: upstream-0.8
ImportĀ upstreamĀ versionĀ 0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
                 *   org.freedesktop.Hal.Device.Volume.InvalidEjectOption
206
206
                 *   org.freedesktop.Hal.Device.Volume.Busy
207
207
                 *   org.freedesktop.Hal.Device.Volume.UnknownFailure
208
 
                 *
 
208
                 *   org.freedesktop.Hal.Device.UnknownError
209
209
                 *
210
210
                 * in a sane way.
211
211
                 */
240
240
                        /* TODO: could add 'Lazy Unmount' button */
241
241
                } else if (strcmp (error_name, "org.freedesktop.Hal.Device.Volume.InvalidUnmountOption") == 0 ||
242
242
                           strcmp (error_name, "org.freedesktop.Hal.Device.Volume.UnsupportedEjectOption") == 0 ||
243
 
                           strcmp (error_name, "org.freedesktop.Hal.Device.Volume.UnknownFailure") == 0) {
244
 
                        gtk_message_dialog_format_secondary_text (
 
243
                           strcmp (error_name, "org.freedesktop.Hal.Device.Volume.UnknownFailure") == 0 ||
 
244
                           strcmp (error_name, "org.freedesktop.Hal.Device.UnknownError") == 0) {
 
245
                        gtk_message_dialog_format_secondary_markup (
245
246
                                GTK_MESSAGE_DIALOG (w),
246
 
                                volume_name != NULL ? 
247
 
                                _("Cannot eject the volume '%s'.") :
248
 
                                _("Cannot eject the volume."),
249
 
                                volume_name);
 
247
                                _("There was an error ejecting the volume or drive."
 
248
                                  "\n"
 
249
                                  "\n"
 
250
                                  "<b>%s:</b> %s"),
 
251
                                error_name,
 
252
                                error_detail);
250
253
                }
251
254
 
252
255
                gtk_dialog_add_buttons (GTK_DIALOG (w),
2159
2162
        LibHalDrive     *drv;
2160
2163
        char            *model;
2161
2164
        char            *vendor;
2162
 
 
 
2165
        char            *title;
2163
2166
 
2164
2167
        keyring_password = NULL;
2165
2168
        keyring_is_session = FALSE;
2229
2232
         */
2230
2233
        notify_parent (TRUE);
2231
2234
 
2232
 
        prompt = g_strdup_printf (
2233
 
                _("The storage device %s contains encrypted data. Enter a password to unlock."), drive_name);
2234
 
        
2235
 
        dialog = gnome_password_dialog_new (_("Unlock Encrypted Data"), prompt, NULL, NULL, FALSE);
 
2235
        if (libhal_volume_is_partition (volume)) {
 
2236
                prompt = g_strdup_printf (_("The storage device %s contains encrypted data on partition %d. "
 
2237
                                            "Enter a password to unlock."),
 
2238
                                          drive_name,
 
2239
                                          libhal_volume_get_partition_number (volume));
 
2240
                title = g_strdup_printf (_("Unlock Encrypted Data (partition %d)"),
 
2241
                                         libhal_volume_get_partition_number (volume));
 
2242
        } else {
 
2243
                prompt = g_strdup_printf (_("The storage device %s contains encrypted data. "
 
2244
                                            "Enter a password to unlock."),
 
2245
                                          drive_name);
 
2246
                title = g_strdup_printf (_("Unlock Encrypted Data"));
 
2247
        }
 
2248
 
 
2249
        dialog = gnome_password_dialog_new (title, prompt, NULL, NULL, FALSE);
2236
2250
        g_free (prompt);
 
2251
        g_free (title);
2237
2252
 
2238
2253
        gnome_password_dialog_set_show_username (GNOME_PASSWORD_DIALOG (dialog), FALSE);
2239
2254
        gnome_password_dialog_set_show_userpass_buttons (GNOME_PASSWORD_DIALOG (dialog), FALSE);
2258
2273
                gnome_password_dialog_set_password (GNOME_PASSWORD_DIALOG (dialog), keyring_password);
2259
2274
        }
2260
2275
 
2261
 
        gtk_widget_show (dialog);
 
2276
        gtk_window_present (GTK_WINDOW (dialog));
2262
2277
 
2263
2278
        if (gnome_password_dialog_run_and_block (GNOME_PASSWORD_DIALOG (dialog)))
2264
2279
        {
2936
2951
                        if (found) {
2937
2952
                                goto try_drive;
2938
2953
                        } else {
 
2954
                                if (opt_eject) {
 
2955
                                        char **volumes_udis;
 
2956
                                        int num_volumes;
 
2957
                                        int n;
 
2958
 
 
2959
                                        /* HACK TODO XXX ALERT: ugh.. try to find a mountable volume with an eject
 
2960
                                         * method..
 
2961
                                         */
 
2962
                                        volumes_udis = libhal_drive_find_all_volumes (hal_ctx, drive, &num_volumes);
 
2963
                                        if (volumes_udis != NULL) {
 
2964
                                                for (n = 0; n < num_volumes; n++) {
 
2965
                                                        char **vol_ifs;
 
2966
                                                        int m;
 
2967
 
 
2968
                                                        vol_ifs = libhal_device_get_property_strlist (
 
2969
                                                                hal_ctx,
 
2970
                                                                volumes_udis[n],
 
2971
                                                                "info.interfaces",
 
2972
                                                                NULL);
 
2973
                                                        if (vol_ifs != NULL) {
 
2974
                                                                for (m = 0; vol_ifs[m] != NULL; m++) {
 
2975
                                                                        if (strcmp (ifs[m], "org.freedesktop.Hal.Device.Volume") == 0) {
 
2976
                                                                                volume = libhal_volume_from_udi (hal_ctx, volumes_udis[n]);
 
2977
                                                                                libhal_drive_free (drive);
 
2978
                                                                                drive = NULL;
 
2979
                                                                                goto try_drive;
 
2980
                                                                        }
 
2981
                                                                }
 
2982
                                                        }
 
2983
                                                        libhal_free_string_array (vol_ifs);
 
2984
                                                }
 
2985
                                                libhal_free_string_array (volumes_udis);
 
2986
                                        }
 
2987
 
 
2988
                                }
 
2989
 
 
2990
 
2939
2991
                                if (opt_verbose)
2940
2992
                                        g_message (_("Drive %s does not contain media."), 
2941
2993
                                                   resolved_device_file != NULL ? resolved_device_file : opt_hal_udi);
3026
3078
                }
3027
3079
 
3028
3080
        } else if (opt_eject) {
3029
 
                if (volume_eject (udi, volume, drive))
3030
 
                        rc = 0;
 
3081
                if (volume_eject (udi, volume, drive))
 
3082
                        rc = 0;
3031
3083
        } else {
3032
3084
                LibHalVolumeUsage fsusage;
3033
3085
 
3051
3103
                                if (opt_verbose)
3052
3104
                                        g_message (_("Crypto volume '%s' is already setup with clear volume '%s'"), 
3053
3105
                                                   udi, clear_udi);
3054
 
                                
 
3106
 
3055
3107
                                free (clear_udi);
3056
3108
                                goto out;
3057
3109
                        }
3058
 
                        
 
3110
 
 
3111
                        /* don't prompt for password if the device is locked
 
3112
                         * (e.g. https://bugzilla.redhat.com/show_bug.cgi?id=437309 )
 
3113
                         */
 
3114
                        if (libhal_device_is_locked_by_others (hal_ctx,
 
3115
                                                               libhal_volume_get_udi (volume),
 
3116
                                                               "org.freedesktop.Hal.Device.Storage",
 
3117
                                                               NULL)) {
 
3118
                                if (opt_verbose)
 
3119
                                        g_message (_("Crypto device %s is locked"),
 
3120
                                                   libhal_volume_get_udi (volume));
 
3121
                                goto out;
 
3122
                        }
 
3123
 
3059
3124
                        g_debug ("Crypto volume - UDI '%s'", udi);
3060
 
                        
 
3125
 
3061
3126
                        setup_success = FALSE;
3062
 
                        
 
3127
 
3063
3128
                        /* we need this to catch when the cleartext device is added */
3064
3129
                        crypto_setup_backing_udi = udi;
3065
3130
                        libhal_ctx_set_device_added (hal_ctx, crypto_setup_device_added);