Add API to allow drive locking
Submitted by Philippe Rouquier
Link to original bug (#627116)
Description
Created attachment 168033 patch to add the above to glib/gio
An API that would allow to set a lock on a GDrive object could be useful in cases where an application would like to tell all other applications that it is using the GDrive and that therefore they should avoid using/accessing it.
Here is the proposal:
typedef enum { G_DRIVE_LOCK_NONE = 0 } GDriveLockFlags;
guint g_drive_obtain_lock_sync (GDrive *drive, GDriveLockFlags flags, const gchar *reason, GCancellable *cancellable, GError error); / Note: error returns the above reason argument set by the process holding the lock if the drive is already locked */
Note about the lock identifier returned by the above function, 0 means failure.
gboolean g_drive_release_lock_sync (GDrive drive, guint lock_id, / a cookie like in Inhibit method */ GError **error);
guint g_file_obtain_lock_finish (GDrive *drive, GAsyncResult *res, GError **error);
gboolean g_file_release_lock_finish (GDrive *drive, GAsyncResult *res, GError **error);
void g_drive_obtain_lock_async (GDrive *drive, GDriveLockFlags flags, const gchar *reason, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
void g_drive_release_lock_async (GDrive *drive, guint lock_id, GAsyncReadyCallback callback, gpointer user_data);
gboolean g_drive_get_is_locked(GDrive);
A new GIOErrorNum: G_IO_ERROR_LOCKED
Patch 168033, "patch to add the above to glib/gio":
glib.diff