/** * gnome_vfs_drive_eject: * @drive: the #GnomeVFSDrive that should be ejcted. * @callback: the #GnomeVFSVolumeOpCallback that should be invoked after ejecting @drive. * @user_data: the user data to pass to @callback. * * If @drive has associated #GnomeVFSVolume objects, all of them will be * unmounted by calling gnome_vfs_volume_unmount() for each volume in * gnome_vfs_drive_get_mounted_volumes(), except for the last one, * for which gnome_vfs_volume_eject() is called to ensure that the * @drive's media is ejected. * * If @drive however has no associated #GnomeVFSVolume objects, it * simply calls an unmount helper on the @drive. * * Since: 2.6 */ void gnome_vfs_drive_eject (GnomeVFSDrive *drive, GnomeVFSVolumeOpCallback callback, gpointer user_data) { GList *vol_list; GList * current_vol; vol_list = gnome_vfs_drive_get_mounted_volumes (drive); for (current_vol = vol_list; current_vol != NULL; current_vol = current_vol->next) { GnomeVFSVolume *vol; vol = GNOME_VFS_VOLUME (current_vol->data); /* Check to see if this is the last volume */ /* If not simply unmount it */ /* If so the eject the media along with the unmount */ if (current_vol->next != NULL) { gnome_vfs_volume_unmount (vol, callback, user_data); } else { gnome_vfs_volume_eject (vol, callback, user_data); } } if (vol_list == NULL) { /* no mounted volumes */ char *mount_path, *device_path, *uri; uri = gnome_vfs_drive_get_activation_uri (drive); mount_path = gnome_vfs_get_local_path_from_uri (uri); g_free (uri); device_path = gnome_vfs_drive_get_device_path (drive); mount_unmount_operation (mount_path, device_path, gnome_vfs_drive_get_hal_udi (drive), GNOME_VFS_DEVICE_TYPE_UNKNOWN, FALSE, FALSE, TRUE, callback, user_data); g_free (mount_path); g_free (device_path); } gnome_vfs_drive_volume_list_free (vol_list); }
/** * gnome_vfs_drive_mount: * @drive: the #GnomeVFSDrive that should be mounted. * @callback: the #GnomeVFSVolumeOpCallback that should be invoked after mounting @drive. * @user_data: the user data to pass to @callback. * * Since: 2.6 */ void gnome_vfs_drive_mount (GnomeVFSDrive *drive, GnomeVFSVolumeOpCallback callback, gpointer user_data) { char *mount_path, *device_path, *uri; uri = gnome_vfs_drive_get_activation_uri (drive); mount_path = gnome_vfs_get_local_path_from_uri (uri); g_free (uri); device_path = gnome_vfs_drive_get_device_path (drive); mount_unmount_operation (mount_path, device_path, gnome_vfs_drive_get_hal_udi (drive), gnome_vfs_drive_get_device_type (drive), TRUE, FALSE, FALSE, callback, user_data); g_free (mount_path); g_free (device_path); }
void _fillin_connected(GnomeVFSDrive * drive, GSList ** p) { Menu_list_item * item; GSList *sublist = *p; char * dev_path; item = g_malloc(sizeof(Menu_list_item)); item->item_type = MENU_ITEM_DRIVE; item->name = g_strdup(gnome_vfs_drive_get_display_name(drive)); item->icon = g_strdup(gnome_vfs_drive_get_icon(drive)); item->drive = drive; /* FIXME gnome_vfs_drive_get_mounted_volume is deprecated.*/ if (gnome_vfs_drive_get_mounted_volume(drive)) { GnomeVFSVolume* volume; volume = gnome_vfs_drive_get_mounted_volume(drive); item->mount_point = gnome_vfs_volume_get_activation_uri(volume); item->drive_prep = NULL; gnome_vfs_volume_unref(volume) ; } else { item->mount_point = g_strdup("Unmounted"); item->drive_prep = _mount_connected; } dev_path = gnome_vfs_drive_get_device_path(drive); item->comment = g_strdup_printf("%s\n%s\n%s", item->name, item->mount_point, dev_path) ; item->desktop = g_strdup(""); sublist = g_slist_append(sublist, item); g_free(dev_path); *p = sublist; }