Add GMountUnmountFlags to all unmount and eject calls. Add
authorAlexander Larsson <alexl@redhat.com>
Thu, 20 Dec 2007 11:48:14 +0000 (11:48 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Thu, 20 Dec 2007 11:48:14 +0000 (11:48 +0000)
2007-12-20  Alexander Larsson  <alexl@redhat.com>

        * 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.

svn path=/trunk/; revision=6169

12 files changed:
gio/ChangeLog
gio/gdrive.c
gio/gdrive.h
gio/gfile.c
gio/gfile.h
gio/gio.symbols
gio/gmount.c
gio/gmount.h
gio/gunixmount.c
gio/gunixvolume.c
gio/gvolume.c
gio/gvolume.h

index 1fecc56d5079aae9e64fea7b886a7a888d35f333..930d939933f48fa5c3bc216069dcba6653e7a205 100644 (file)
@@ -1,3 +1,16 @@
+2007-12-20  Alexander Larsson  <alexl@redhat.com>
+
+        * 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  <alexl@redhat.com>
 
        * gvfs.c (get_default_vfs):
index b047774b50d63ad64528603d7828db5f64f6f7e6..eec59484324510d5cdc72069e17987510b0154b2 100644 (file)
@@ -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);
 }
 
 /**
index 230d02e1f5a5c100a94456de15ded171c940b82f..0901099f411632a5113dce1625aedafe2967a855 100644 (file)
@@ -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);
index e651bed2358c6b02aeb0044414fce6039b4494ba..23a1826279703c981ca85796761284dec0f16ec6 100644 (file)
@@ -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);
index d83d0f58e4ce66cb1da7164132669a76ee7bf775..5083f11da6a8c8a55ee2afbf75ce372656045424 100644 (file)
@@ -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);
index 45d2014ac6113b264d539aa1dcc81e0ed68de10f..c487f4d6c87c890109b5652e4a113ad7ece5bad3 100644 (file)
@@ -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
index 3b4d297992add69490713e88c9cabb6ca5215ea6..b6f0df1751e13df2099dc1d8fd688b63ae923e43 100644 (file)
@@ -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"
index 46958f972906946443dce4dcb1f031f6e303f032..6b3149397689e1942bc838cdbbab6d7467b99601 100644 (file)
@@ -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
 
index ea6e1992cac50d450d17651911efd1c8a776194b..ca451fcf206d81e2ecba00ef94f2db55fdff7985 100644 (file)
@@ -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)
index 3b9928e0ef7e86d92931b473d1955d14eccb983c..23516f1fac2917fb3ef56f6cc264ec7b7e098b10 100644 (file)
@@ -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)
index 84d0a2c41564e6d071ab71afcf677db3d222d4b7..5eb1e49e4ddc4f7f7c483fa0f868cb87cc839ef6 100644 (file)
@@ -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);
 }
 
 /**
index bef590ea8b1e6be451b9c1bf929dbcffcd62b97a..2d71ae26e1f33eda59de0b2778d7f96c11020c05 100644 (file)
@@ -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);