diff --git a/gio/ChangeLog b/gio/ChangeLog index 1fecc56d5..930d93993 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,16 @@ +2007-12-20 Alexander Larsson + + * gfile.[ch]: + * gdrive.[ch]: + * gmount.[ch]: + * gvolume.[ch]: + * gunixmount.c: + * gunixvolume.c: + * gio.symbols: + Add GMountUnmountFlags to all unmount and + eject calls. + Add g_mount_remount() call. + 2007-12-20 Alexander Larsson * gvfs.c (get_default_vfs): diff --git a/gio/gdrive.c b/gio/gdrive.c index b047774b5..eec594843 100644 --- a/gio/gdrive.c +++ b/gio/gdrive.c @@ -337,6 +337,7 @@ g_drive_can_poll_for_media (GDrive *drive) /** * g_drive_eject: * @drive: a #GDrive. + * @flags: flags affecting the unmount if required for eject * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback. * @user_data: a #gpointer. @@ -346,6 +347,7 @@ g_drive_can_poll_for_media (GDrive *drive) **/ void g_drive_eject (GDrive *drive, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -365,7 +367,7 @@ g_drive_eject (GDrive *drive, return; } - (* iface->eject) (drive, cancellable, callback, user_data); + (* iface->eject) (drive, flags, cancellable, callback, user_data); } /** diff --git a/gio/gdrive.h b/gio/gdrive.h index 230d02e1f..0901099f4 100644 --- a/gio/gdrive.h +++ b/gio/gdrive.h @@ -84,6 +84,7 @@ struct _GDriveIface gboolean (*can_eject) (GDrive *drive); gboolean (*can_poll_for_media) (GDrive *drive); void (*eject) (GDrive *drive, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -111,6 +112,7 @@ gboolean g_drive_is_media_check_automatic (GDrive *drive); gboolean g_drive_can_poll_for_media (GDrive *drive); gboolean g_drive_can_eject (GDrive *drive); void g_drive_eject (GDrive *drive, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); diff --git a/gio/gfile.c b/gio/gfile.c index e651bed23..23a182627 100644 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -3078,6 +3078,7 @@ g_file_mount_mountable_finish (GFile *file, /** * g_file_unmount_mountable: * @file: input #GFile. + * @flags: flags affecting the operation * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback to call when the request is satisfied * @user_data: the data to pass to callback function @@ -3093,6 +3094,7 @@ g_file_mount_mountable_finish (GFile *file, **/ void g_file_unmount_mountable (GFile *file, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -3112,6 +3114,7 @@ g_file_unmount_mountable (GFile *file, _("Operation not supported")); (* iface->unmount_mountable) (file, + flags, cancellable, callback, user_data); @@ -3155,6 +3158,7 @@ g_file_unmount_mountable_finish (GFile *file, /** * g_file_eject_mountable: * @file: input #GFile. + * @flags: flags affecting the operation * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback to call when the request is satisfied * @user_data: the data to pass to callback function @@ -3170,6 +3174,7 @@ g_file_unmount_mountable_finish (GFile *file, **/ void g_file_eject_mountable (GFile *file, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -3189,6 +3194,7 @@ g_file_eject_mountable (GFile *file, _("Operation not supported")); (* iface->eject_mountable) (file, + flags, cancellable, callback, user_data); diff --git a/gio/gfile.h b/gio/gfile.h index d83d0f58e..5083f11da 100644 --- a/gio/gfile.h +++ b/gio/gfile.h @@ -66,6 +66,19 @@ typedef enum { G_FILE_CREATE_PRIVATE = (1<<0) } GFileCreateFlags; +/** + * GMountUnmountFlags: + * @G_MOUNT_UNMOUNT_NONE: No flags set. + * @G_MOUNT_UNMOUNT_FORCE: Unmount even if there are outstanding + * file operations on the mount. + * + * Flags used when an operation may create a file. + */ +typedef enum { + G_MOUNT_UNMOUNT_NONE = 0, + G_MOUNT_UNMOUNT_FORCE = (1<<0) +} GMountUnmountFlags; + /** * GFileCopyFlags: * @G_FILE_COPY_NONE: No flags set. @@ -478,6 +491,7 @@ struct _GFileIface GAsyncResult *result, GError **error); void (*unmount_mountable) (GFile *file, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -485,6 +499,7 @@ struct _GFileIface GAsyncResult *result, GError **error); void (*eject_mountable) (GFile *file, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -755,6 +770,7 @@ GFile * g_file_mount_mountable_finish (GFile GAsyncResult *result, GError **error); void g_file_unmount_mountable (GFile *file, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -762,6 +778,7 @@ gboolean g_file_unmount_mountable_finish (GFile GAsyncResult *result, GError **error); void g_file_eject_mountable (GFile *file, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); diff --git a/gio/gio.symbols b/gio/gio.symbols index 45d2014ac..c487f4d6c 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -692,6 +692,8 @@ g_mount_unmount g_mount_unmount_finish g_mount_eject g_mount_eject_finish +g_mount_remount +g_mount_remount_finish #endif #endif @@ -751,6 +753,7 @@ g_local_directory_monitor_get_type G_GNUC_CONST #if IN_HEADER(__GIO_ENUM_TYPES_H__) #if IN_FILE(__GIO_ENUM_TYPES_C__) +g_mount_unmount_flags_get_type G_GNUC_CONST g_app_info_create_flags_get_type G_GNUC_CONST g_data_stream_byte_order_get_type G_GNUC_CONST g_data_stream_newline_type_get_type G_GNUC_CONST diff --git a/gio/gmount.c b/gio/gmount.c index 3b4d29799..b6f0df175 100644 --- a/gio/gmount.c +++ b/gio/gmount.c @@ -305,6 +305,7 @@ g_mount_can_eject (GMount *mount) /** * g_mount_unmount: * @mount: a #GMount. + * @flags: flags affecting the operation * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback. * @user_data: user data passed to @callback. @@ -314,10 +315,11 @@ g_mount_can_eject (GMount *mount) * and #GAsyncResults data returned in the @callback. **/ void -g_mount_unmount (GMount *mount, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +g_mount_unmount (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { GMountIface *iface; @@ -335,7 +337,7 @@ g_mount_unmount (GMount *mount, return; } - (* iface->unmount) (mount, cancellable, callback, user_data); + (* iface->unmount) (mount, flags, cancellable, callback, user_data); } /** @@ -375,6 +377,7 @@ g_mount_unmount_finish (GMount *mount, /** * g_mount_eject: * @mount: a #GMount. + * @flags: flags affecting the unmount if required for eject * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback. * @user_data: user data passed to @callback. @@ -384,10 +387,11 @@ g_mount_unmount_finish (GMount *mount, * and #GAsyncResults data returned in the @callback. **/ void -g_mount_eject (GMount *mount, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +g_mount_eject (GMount *mount, + GMountUnmountFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { GMountIface *iface; @@ -405,7 +409,7 @@ g_mount_eject (GMount *mount, return; } - (* iface->eject) (mount, cancellable, callback, user_data); + (* iface->eject) (mount, flags, cancellable, callback, user_data); } /** @@ -441,5 +445,83 @@ g_mount_eject_finish (GMount *mount, return (* iface->eject_finish) (mount, result, error); } +/** + * g_mount_remount: + * @mount: a #GMount. + * @mount_operation: a #GMountOperation or %NULL to avoid user interaction. + * @cancellable: optional #GCancellable object, %NULL to ignore. + * @callback: a #GAsyncReadyCallback. + * @user_data: user data passed to @callback. + * + * Remounts a mount. This is an asynchronous operation, and is + * finished by calling g_mount_unmount_finish() with the @mount + * and #GAsyncResults data returned in the @callback. + * + * Remounting is useful when some setting affecting the operation + * of the volume has been changed, as these may need a remount to + * take affect. While this is semantically equivalent with unmounting + * and then remounting not all backends might need to actually be + * unmounted. + **/ +void +g_mount_remount (GMount *mount, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GMountIface *iface; + + g_return_if_fail (G_IS_MOUNT (mount)); + + iface = G_MOUNT_GET_IFACE (mount); + + if (iface->remount == NULL) + { + g_simple_async_report_error_in_idle (G_OBJECT (mount), + callback, user_data, + G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + _("mount doesn't implement remount")); + + return; + } + + (* iface->remount) (mount, mount_operation, cancellable, callback, user_data); +} + +/** + * g_mount_remount_finish: + * @mount: a #GMount. + * @result: a #GAsyncResult. + * @error: a #GError location to store the error occuring, or %NULL to + * ignore. + * + * Finishes remounting a mount. If any errors occured during the operation, + * @error will be set to contain the errors and %FALSE will be returned. + * + * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise. + **/ +gboolean +g_mount_remount_finish (GMount *mount, + GAsyncResult *result, + GError **error) +{ + GMountIface *iface; + + g_return_val_if_fail (G_IS_MOUNT (mount), FALSE); + g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE); + + if (G_IS_SIMPLE_ASYNC_RESULT (result)) + { + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) + return FALSE; + } + + iface = G_MOUNT_GET_IFACE (mount); + return (* iface->remount_finish) (mount, result, error); +} + + #define __G_MOUNT_C__ #include "gioaliasdef.c" diff --git a/gio/gmount.h b/gio/gmount.h index 46958f972..6b3149397 100644 --- a/gio/gmount.h +++ b/gio/gmount.h @@ -95,6 +95,7 @@ struct _GMountIface gboolean (*can_unmount) (GMount *mount); gboolean (*can_eject) (GMount *mount); void (*unmount) (GMount *mount, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -102,12 +103,21 @@ struct _GMountIface GAsyncResult *result, GError **error); void (*eject) (GMount *mount, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean (*eject_finish) (GMount *mount, GAsyncResult *result, GError **error); + void (*remount) (GMount *mount, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*remount_finish) (GMount *mount, + GAsyncResult *result, + GError **error); }; GType g_mount_get_type (void) G_GNUC_CONST; @@ -121,6 +131,7 @@ GDrive * g_mount_get_drive (GMount *mount); gboolean g_mount_can_unmount (GMount *mount); gboolean g_mount_can_eject (GMount *mount); void g_mount_unmount (GMount *mount, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -128,12 +139,21 @@ gboolean g_mount_unmount_finish (GMount *mount, GAsyncResult *result, GError **error); void g_mount_eject (GMount *mount, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean g_mount_eject_finish (GMount *mount, GAsyncResult *result, GError **error); +void g_mount_remount (GMount *mount, + GMountOperation *mount_operation, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean g_mount_remount_finish (GMount *mount, + GAsyncResult *result, + GError **error); G_END_DECLS diff --git a/gio/gunixmount.c b/gio/gunixmount.c index ea6e1992c..ca451fcf2 100644 --- a/gio/gunixmount.c +++ b/gio/gunixmount.c @@ -340,6 +340,7 @@ eject_unmount_do (GMount *mount, static void g_unix_mount_unmount (GMount *mount, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -365,6 +366,7 @@ g_unix_mount_unmount_finish (GMount *mount, static void g_unix_mount_eject (GMount *mount, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) diff --git a/gio/gunixvolume.c b/gio/gunixvolume.c index 3b9928e0e..23516f1fa 100644 --- a/gio/gunixvolume.c +++ b/gio/gunixvolume.c @@ -381,6 +381,7 @@ g_unix_volume_mount_finish (GVolume *volume, static void g_unix_volume_eject (GVolume *volume, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) diff --git a/gio/gvolume.c b/gio/gvolume.c index 84d0a2c41..5eb1e49e4 100644 --- a/gio/gvolume.c +++ b/gio/gvolume.c @@ -357,6 +357,7 @@ g_volume_mount_finish (GVolume *volume, /** * g_volume_eject: * @volume: a #GVolume. + * @flags: flags affecting the unmount if required for eject * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback. * @user_data: a #gpointer. @@ -365,6 +366,7 @@ g_volume_mount_finish (GVolume *volume, **/ void g_volume_eject (GVolume *volume, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -384,7 +386,7 @@ g_volume_eject (GVolume *volume, return; } - (* iface->eject) (volume, cancellable, callback, user_data); + (* iface->eject) (volume, flags, cancellable, callback, user_data); } /** diff --git a/gio/gvolume.h b/gio/gvolume.h index bef590ea8..2d71ae26e 100644 --- a/gio/gvolume.h +++ b/gio/gvolume.h @@ -87,6 +87,7 @@ struct _GVolumeIface GAsyncResult *result, GError **error); void (*eject) (GVolume *volume, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -113,6 +114,7 @@ gboolean g_volume_mount_finish (GVolume *volume, GAsyncResult *result, GError **error); void g_volume_eject (GVolume *volume, + GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);