mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 10:16:17 +01:00
gio: port file/vfs-related classes from GSimpleAsyncResult to GTask
https://bugzilla.gnome.org/show_bug.cgi?id=661767
This commit is contained in:
parent
669505e354
commit
ed5accf16c
56
gio/gdrive.c
56
gio/gdrive.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "gdrive.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gthemedicon.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gioerror.h"
|
||||
@ -388,10 +388,10 @@ g_drive_eject (GDrive *drive,
|
||||
|
||||
if (iface->eject == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (drive), callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement eject"));
|
||||
|
||||
g_task_report_new_error (drive, callback, user_data,
|
||||
g_drive_eject_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement eject"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -423,6 +423,8 @@ g_drive_eject_finish (GDrive *drive,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_drive_eject_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_DRIVE_GET_IFACE (drive);
|
||||
|
||||
@ -461,13 +463,13 @@ g_drive_eject_with_operation (GDrive *drive,
|
||||
|
||||
if (iface->eject == NULL && iface->eject_with_operation == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (drive),
|
||||
callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for drive objects that
|
||||
* don't implement any of eject or eject_with_operation. */
|
||||
_("drive doesn't implement eject or eject_with_operation"));
|
||||
g_task_report_new_error (drive, callback, user_data,
|
||||
g_drive_eject_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for drive objects that
|
||||
* don't implement any of eject or eject_with_operation. */
|
||||
_("drive doesn't implement eject or eject_with_operation"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -503,6 +505,8 @@ g_drive_eject_with_operation_finish (GDrive *drive,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_drive_eject_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_DRIVE_GET_IFACE (drive);
|
||||
if (iface->eject_with_operation_finish != NULL)
|
||||
@ -538,10 +542,10 @@ g_drive_poll_for_media (GDrive *drive,
|
||||
|
||||
if (iface->poll_for_media == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (drive), callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement polling for media"));
|
||||
|
||||
g_task_report_new_error (drive, callback, user_data,
|
||||
g_drive_poll_for_media,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement polling for media"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -571,6 +575,8 @@ g_drive_poll_for_media_finish (GDrive *drive,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_drive_poll_for_media))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_DRIVE_GET_IFACE (drive);
|
||||
|
||||
@ -741,9 +747,10 @@ g_drive_start (GDrive *drive,
|
||||
|
||||
if (iface->start == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (drive), callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement start"));
|
||||
g_task_report_new_error (drive, callback, user_data,
|
||||
g_drive_start,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement start"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -775,6 +782,8 @@ g_drive_start_finish (GDrive *drive,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_drive_start))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_DRIVE_GET_IFACE (drive);
|
||||
|
||||
@ -840,9 +849,10 @@ g_drive_stop (GDrive *drive,
|
||||
|
||||
if (iface->stop == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (drive), callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement stop"));
|
||||
g_task_report_new_error (drive, callback, user_data,
|
||||
g_drive_start,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("drive doesn't implement stop"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -874,6 +884,8 @@ g_drive_stop_finish (GDrive *drive,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_drive_start))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_DRIVE_GET_IFACE (drive);
|
||||
|
||||
|
937
gio/gfile.c
937
gio/gfile.c
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,6 @@
|
||||
#include "gioscheduler.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gasynchelper.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
@ -335,7 +334,6 @@ g_file_enumerator_next_files_async (GFileEnumerator *enumerator,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFileEnumeratorClass *class;
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
g_return_if_fail (G_IS_FILE_ENUMERATOR (enumerator));
|
||||
g_return_if_fail (enumerator != NULL);
|
||||
@ -343,32 +341,30 @@ g_file_enumerator_next_files_async (GFileEnumerator *enumerator,
|
||||
|
||||
if (num_files == 0)
|
||||
{
|
||||
simple = g_simple_async_result_new (G_OBJECT (enumerator),
|
||||
callback,
|
||||
user_data,
|
||||
g_file_enumerator_next_files_async);
|
||||
g_simple_async_result_complete_in_idle (simple);
|
||||
g_object_unref (simple);
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (enumerator, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, g_file_enumerator_next_files_async);
|
||||
g_task_return_pointer (task, NULL, NULL);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
if (enumerator->priv->closed)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (enumerator),
|
||||
callback,
|
||||
user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_CLOSED,
|
||||
_("File enumerator is already closed"));
|
||||
g_task_report_new_error (enumerator, callback, user_data,
|
||||
g_file_enumerator_next_files_async,
|
||||
G_IO_ERROR, G_IO_ERROR_CLOSED,
|
||||
_("File enumerator is already closed"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (enumerator->priv->pending)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (enumerator),
|
||||
callback,
|
||||
user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_PENDING,
|
||||
_("File enumerator has outstanding operation"));
|
||||
g_task_report_new_error (enumerator, callback, user_data,
|
||||
g_file_enumerator_next_files_async,
|
||||
G_IO_ERROR, G_IO_ERROR_PENDING,
|
||||
_("File enumerator has outstanding operation"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -407,10 +403,7 @@ g_file_enumerator_next_files_finish (GFileEnumerator *enumerator,
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return NULL;
|
||||
else if (g_async_result_is_tagged (result, g_file_enumerator_next_files_async))
|
||||
{
|
||||
/* Special case read of 0 files */
|
||||
return NULL;
|
||||
}
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
|
||||
class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
|
||||
return class->next_files_finish (enumerator, result, error);
|
||||
@ -459,21 +452,19 @@ g_file_enumerator_close_async (GFileEnumerator *enumerator,
|
||||
|
||||
if (enumerator->priv->closed)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (enumerator),
|
||||
callback,
|
||||
user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_CLOSED,
|
||||
_("File enumerator is already closed"));
|
||||
g_task_report_new_error (enumerator, callback, user_data,
|
||||
g_file_enumerator_close_async,
|
||||
G_IO_ERROR, G_IO_ERROR_CLOSED,
|
||||
_("File enumerator is already closed"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (enumerator->priv->pending)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (enumerator),
|
||||
callback,
|
||||
user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_PENDING,
|
||||
_("File enumerator has outstanding operation"));
|
||||
g_task_report_new_error (enumerator, callback, user_data,
|
||||
g_file_enumerator_close_async,
|
||||
G_IO_ERROR, G_IO_ERROR_PENDING,
|
||||
_("File enumerator has outstanding operation"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -518,6 +509,8 @@ g_file_enumerator_close_finish (GFileEnumerator *enumerator,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_file_enumerator_close_async))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
|
||||
return class->close_finish (enumerator, result, error);
|
||||
@ -620,40 +613,29 @@ g_file_enumerator_get_child (GFileEnumerator *enumerator,
|
||||
g_file_info_get_name (info));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int num_files;
|
||||
GList *files;
|
||||
} NextAsyncOp;
|
||||
|
||||
static void
|
||||
next_async_op_free (NextAsyncOp *op)
|
||||
next_async_op_free (GList *files)
|
||||
{
|
||||
/* Free the list, if finish wasn't called */
|
||||
g_list_free_full (op->files, g_object_unref);
|
||||
|
||||
g_free (op);
|
||||
g_list_free_full (files, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
next_files_thread (GSimpleAsyncResult *res,
|
||||
GObject *object,
|
||||
GCancellable *cancellable)
|
||||
next_files_thread (GTask *task,
|
||||
gpointer source_object,
|
||||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
NextAsyncOp *op;
|
||||
GFileEnumerator *enumerator = source_object;
|
||||
int num_files = GPOINTER_TO_INT (task_data);
|
||||
GFileEnumeratorClass *class;
|
||||
GList *files = NULL;
|
||||
GError *error = NULL;
|
||||
GFileInfo *info;
|
||||
GFileEnumerator *enumerator;
|
||||
int i;
|
||||
|
||||
enumerator = G_FILE_ENUMERATOR (object);
|
||||
op = g_simple_async_result_get_op_res_gpointer (res);
|
||||
class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
|
||||
|
||||
class = G_FILE_ENUMERATOR_GET_CLASS (object);
|
||||
|
||||
for (i = 0; i < op->num_files; i++)
|
||||
for (i = 0; i < num_files; i++)
|
||||
{
|
||||
if (g_cancellable_set_error_if_cancelled (cancellable, &error))
|
||||
info = NULL;
|
||||
@ -665,8 +647,7 @@ next_files_thread (GSimpleAsyncResult *res,
|
||||
/* If we get an error after first file, return that on next operation */
|
||||
if (error != NULL && i > 0)
|
||||
{
|
||||
if (error->domain == G_IO_ERROR &&
|
||||
error->code == G_IO_ERROR_CANCELLED)
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_error_free (error); /* Never propagate cancel errors to other call */
|
||||
else
|
||||
enumerator->priv->outstanding_error = error;
|
||||
@ -676,8 +657,13 @@ next_files_thread (GSimpleAsyncResult *res,
|
||||
break;
|
||||
}
|
||||
else
|
||||
op->files = g_list_prepend (op->files, info);
|
||||
files = g_list_prepend (files, info);
|
||||
}
|
||||
|
||||
if (error)
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_pointer (task, files, (GDestroyNotify)next_async_op_free);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -688,19 +674,14 @@ g_file_enumerator_real_next_files_async (GFileEnumerator *enumerator,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
NextAsyncOp *op;
|
||||
GTask *task;
|
||||
|
||||
op = g_new0 (NextAsyncOp, 1);
|
||||
task = g_task_new (enumerator, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, GINT_TO_POINTER (num_files), NULL);
|
||||
g_task_set_priority (task, io_priority);
|
||||
|
||||
op->num_files = num_files;
|
||||
op->files = NULL;
|
||||
|
||||
res = g_simple_async_result_new (G_OBJECT (enumerator), callback, user_data, g_file_enumerator_real_next_files_async);
|
||||
g_simple_async_result_set_op_res_gpointer (res, op, (GDestroyNotify) next_async_op_free);
|
||||
|
||||
g_simple_async_result_run_in_thread (res, next_files_thread, io_priority, cancellable);
|
||||
g_object_unref (res);
|
||||
g_task_run_in_thread (task, next_files_thread);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static GList *
|
||||
@ -708,44 +689,30 @@ g_file_enumerator_real_next_files_finish (GFileEnumerator *enumer
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
|
||||
NextAsyncOp *op;
|
||||
GList *res;
|
||||
g_return_val_if_fail (g_task_is_valid (result, enumerator), NULL);
|
||||
|
||||
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
|
||||
g_file_enumerator_real_next_files_async);
|
||||
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return NULL;
|
||||
|
||||
op = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
|
||||
res = op->files;
|
||||
op->files = NULL;
|
||||
return res;
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
static void
|
||||
close_async_thread (GSimpleAsyncResult *res,
|
||||
GObject *object,
|
||||
GCancellable *cancellable)
|
||||
close_async_thread (GTask *task,
|
||||
gpointer source_object,
|
||||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
GFileEnumerator *enumerator = source_object;
|
||||
GFileEnumeratorClass *class;
|
||||
GError *error = NULL;
|
||||
gboolean result;
|
||||
|
||||
/* Auto handling of cancelation disabled, and ignore
|
||||
cancellation, since we want to close things anyway, although
|
||||
possibly in a quick-n-dirty way. At least we never want to leak
|
||||
open handles */
|
||||
|
||||
class = G_FILE_ENUMERATOR_GET_CLASS (object);
|
||||
result = class->close_fn (G_FILE_ENUMERATOR (object), cancellable, &error);
|
||||
if (!result)
|
||||
g_simple_async_result_take_error (res, error);
|
||||
class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
|
||||
result = class->close_fn (enumerator, cancellable, &error);
|
||||
if (result)
|
||||
g_task_return_boolean (task, TRUE);
|
||||
else
|
||||
g_task_return_error (task, error);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
g_file_enumerator_real_close_async (GFileEnumerator *enumerator,
|
||||
int io_priority,
|
||||
@ -753,20 +720,13 @@ g_file_enumerator_real_close_async (GFileEnumerator *enumerator,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
|
||||
res = g_simple_async_result_new (G_OBJECT (enumerator),
|
||||
callback,
|
||||
user_data,
|
||||
g_file_enumerator_real_close_async);
|
||||
GTask *task;
|
||||
|
||||
g_simple_async_result_set_handle_cancellation (res, FALSE);
|
||||
task = g_task_new (enumerator, cancellable, callback, user_data);
|
||||
g_task_set_priority (task, io_priority);
|
||||
|
||||
g_simple_async_result_run_in_thread (res,
|
||||
close_async_thread,
|
||||
io_priority,
|
||||
cancellable);
|
||||
g_object_unref (res);
|
||||
g_task_run_in_thread (task, close_async_thread);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -774,13 +734,7 @@ g_file_enumerator_real_close_finish (GFileEnumerator *enumerator,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
|
||||
g_return_val_if_fail (g_task_is_valid (result, enumerator), FALSE);
|
||||
|
||||
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
|
||||
g_file_enumerator_real_close_async);
|
||||
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "glibintl.h"
|
||||
#include "gloadableicon.h"
|
||||
#include "ginputstream.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gioerror.h"
|
||||
|
||||
|
||||
@ -283,19 +283,6 @@ g_file_icon_load (GLoadableIcon *icon,
|
||||
return G_INPUT_STREAM (stream);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GLoadableIcon *icon;
|
||||
GAsyncReadyCallback callback;
|
||||
gpointer user_data;
|
||||
} LoadData;
|
||||
|
||||
static void
|
||||
load_data_free (LoadData *data)
|
||||
{
|
||||
g_object_unref (data->icon);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
load_async_callback (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
@ -303,35 +290,14 @@ load_async_callback (GObject *source_object,
|
||||
{
|
||||
GFileInputStream *stream;
|
||||
GError *error = NULL;
|
||||
GSimpleAsyncResult *simple;
|
||||
LoadData *data = user_data;
|
||||
GTask *task = user_data;
|
||||
|
||||
stream = g_file_read_finish (G_FILE (source_object), res, &error);
|
||||
|
||||
if (stream == NULL)
|
||||
{
|
||||
simple = g_simple_async_result_new_take_error (G_OBJECT (data->icon),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
error);
|
||||
}
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
{
|
||||
simple = g_simple_async_result_new (G_OBJECT (data->icon),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
g_file_icon_load_async);
|
||||
|
||||
g_simple_async_result_set_op_res_gpointer (simple,
|
||||
stream,
|
||||
g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
g_simple_async_result_complete (simple);
|
||||
|
||||
load_data_free (data);
|
||||
g_object_unref (simple);
|
||||
g_task_return_pointer (task, stream, g_object_unref);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -342,17 +308,13 @@ g_file_icon_load_async (GLoadableIcon *icon,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFileIcon *file_icon = G_FILE_ICON (icon);
|
||||
LoadData *data;
|
||||
GTask *task;
|
||||
|
||||
data = g_new0 (LoadData, 1);
|
||||
data->icon = g_object_ref (icon);
|
||||
data->callback = callback;
|
||||
data->user_data = user_data;
|
||||
task = g_task_new (icon, cancellable, callback, user_data);
|
||||
|
||||
g_file_read_async (file_icon->file, 0,
|
||||
cancellable,
|
||||
load_async_callback, data);
|
||||
|
||||
cancellable,
|
||||
load_async_callback, task);
|
||||
}
|
||||
|
||||
static GInputStream *
|
||||
@ -361,19 +323,12 @@ g_file_icon_load_finish (GLoadableIcon *icon,
|
||||
char **type,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
||||
gpointer op;
|
||||
|
||||
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_icon_load_async);
|
||||
g_return_val_if_fail (g_task_is_valid (res, icon), NULL);
|
||||
|
||||
if (type)
|
||||
*type = NULL;
|
||||
|
||||
op = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
if (op)
|
||||
return g_object_ref (op);
|
||||
|
||||
return NULL;
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -25,9 +25,9 @@
|
||||
#include <glib.h>
|
||||
#include <gfileinputstream.h>
|
||||
#include <gseekable.h>
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gcancellable.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
@ -215,10 +215,9 @@ g_file_input_stream_query_info_async (GFileInputStream *stream,
|
||||
|
||||
if (!g_input_stream_set_pending (input_stream, &error))
|
||||
{
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
|
||||
callback,
|
||||
user_data,
|
||||
error);
|
||||
g_task_report_error (stream, callback, user_data,
|
||||
g_file_input_stream_query_info_async,
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -227,7 +226,7 @@ g_file_input_stream_query_info_async (GFileInputStream *stream,
|
||||
stream->priv->outstanding_callback = callback;
|
||||
g_object_ref (stream);
|
||||
klass->query_info_async (stream, attributes, io_priority, cancellable,
|
||||
async_ready_callback_wrapper, user_data);
|
||||
async_ready_callback_wrapper, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,6 +252,8 @@ g_file_input_stream_query_info_finish (GFileInputStream *stream,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return NULL;
|
||||
else if (g_async_result_is_tagged (result, g_file_input_stream_query_info_async))
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
|
||||
class = G_FILE_INPUT_STREAM_GET_CLASS (stream);
|
||||
return class->query_info_finish (stream, result, error);
|
||||
@ -379,45 +380,29 @@ g_file_input_stream_seekable_truncate (GSeekable *seekable,
|
||||
* Default implementation of async ops *
|
||||
********************************************/
|
||||
|
||||
typedef struct {
|
||||
char *attributes;
|
||||
GFileInfo *info;
|
||||
} QueryInfoAsyncData;
|
||||
|
||||
static void
|
||||
query_info_data_free (QueryInfoAsyncData *data)
|
||||
{
|
||||
if (data->info)
|
||||
g_object_unref (data->info);
|
||||
g_free (data->attributes);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
query_info_async_thread (GSimpleAsyncResult *res,
|
||||
GObject *object,
|
||||
GCancellable *cancellable)
|
||||
query_info_async_thread (GTask *task,
|
||||
gpointer source_object,
|
||||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
GFileInputStream *stream = source_object;
|
||||
const char *attributes = task_data;
|
||||
GFileInputStreamClass *class;
|
||||
GError *error = NULL;
|
||||
QueryInfoAsyncData *data;
|
||||
GFileInfo *info;
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (res);
|
||||
GFileInfo *info = NULL;
|
||||
|
||||
info = NULL;
|
||||
|
||||
class = G_FILE_INPUT_STREAM_GET_CLASS (object);
|
||||
class = G_FILE_INPUT_STREAM_GET_CLASS (stream);
|
||||
if (class->query_info)
|
||||
info = class->query_info (G_FILE_INPUT_STREAM (object), data->attributes, cancellable, &error);
|
||||
info = class->query_info (stream, attributes, cancellable, &error);
|
||||
else
|
||||
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Stream doesn't support query_info"));
|
||||
|
||||
if (info == NULL)
|
||||
g_simple_async_result_take_error (res, error);
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
data->info = info;
|
||||
g_task_return_pointer (task, info, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -428,17 +413,14 @@ g_file_input_stream_real_query_info_async (GFileInputStream *stream,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
QueryInfoAsyncData *data;
|
||||
GTask *task;
|
||||
|
||||
data = g_new0 (QueryInfoAsyncData, 1);
|
||||
data->attributes = g_strdup (attributes);
|
||||
task = g_task_new (stream, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, g_strdup (attributes), g_free);
|
||||
g_task_set_priority (task, io_priority);
|
||||
|
||||
res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_file_input_stream_real_query_info_async);
|
||||
g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)query_info_data_free);
|
||||
|
||||
g_simple_async_result_run_in_thread (res, query_info_async_thread, io_priority, cancellable);
|
||||
g_object_unref (res);
|
||||
g_task_run_in_thread (task, query_info_async_thread);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static GFileInfo *
|
||||
@ -446,17 +428,7 @@ g_file_input_stream_real_query_info_finish (GFileInputStream *stream,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
||||
QueryInfoAsyncData *data;
|
||||
g_return_val_if_fail (g_task_is_valid (res, stream), NULL);
|
||||
|
||||
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_input_stream_real_query_info_async);
|
||||
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return NULL;
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
if (data->info)
|
||||
return g_object_ref (data->info);
|
||||
|
||||
return NULL;
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include <glib.h>
|
||||
#include <gfileiostream.h>
|
||||
#include <gseekable.h>
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gcancellable.h"
|
||||
#include "gioerror.h"
|
||||
#include "gfileoutputstream.h"
|
||||
@ -227,10 +227,9 @@ g_file_io_stream_query_info_async (GFileIOStream *stream,
|
||||
|
||||
if (!g_io_stream_set_pending (io_stream, &error))
|
||||
{
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
|
||||
callback,
|
||||
user_data,
|
||||
error);
|
||||
g_task_report_error (stream, callback, user_data,
|
||||
g_file_io_stream_query_info_async,
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -239,7 +238,7 @@ g_file_io_stream_query_info_async (GFileIOStream *stream,
|
||||
stream->priv->outstanding_callback = callback;
|
||||
g_object_ref (stream);
|
||||
klass->query_info_async (stream, attributes, io_priority, cancellable,
|
||||
async_ready_callback_wrapper, user_data);
|
||||
async_ready_callback_wrapper, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -267,6 +266,8 @@ g_file_io_stream_query_info_finish (GFileIOStream *stream,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return NULL;
|
||||
else if (g_async_result_is_tagged (result, g_file_io_stream_query_info_async))
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
|
||||
class = G_FILE_IO_STREAM_GET_CLASS (stream);
|
||||
return class->query_info_finish (stream, result, error);
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include <glib.h>
|
||||
#include <gfileoutputstream.h>
|
||||
#include <gseekable.h>
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gcancellable.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
@ -225,10 +225,9 @@ g_file_output_stream_query_info_async (GFileOutputStream *stream,
|
||||
|
||||
if (!g_output_stream_set_pending (output_stream, &error))
|
||||
{
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
|
||||
callback,
|
||||
user_data,
|
||||
error);
|
||||
g_task_report_error (stream, callback, user_data,
|
||||
g_file_output_stream_query_info_async,
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -237,7 +236,7 @@ g_file_output_stream_query_info_async (GFileOutputStream *stream,
|
||||
stream->priv->outstanding_callback = callback;
|
||||
g_object_ref (stream);
|
||||
klass->query_info_async (stream, attributes, io_priority, cancellable,
|
||||
async_ready_callback_wrapper, user_data);
|
||||
async_ready_callback_wrapper, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,6 +262,8 @@ g_file_output_stream_query_info_finish (GFileOutputStream *stream,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return NULL;
|
||||
else if (g_async_result_is_tagged (result, g_file_output_stream_query_info_async))
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
|
||||
class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
|
||||
return class->query_info_finish (stream, result, error);
|
||||
@ -482,45 +483,29 @@ g_file_output_stream_seekable_truncate (GSeekable *seekable,
|
||||
* Default implementation of async ops *
|
||||
********************************************/
|
||||
|
||||
typedef struct {
|
||||
char *attributes;
|
||||
GFileInfo *info;
|
||||
} QueryInfoAsyncData;
|
||||
|
||||
static void
|
||||
query_info_data_free (QueryInfoAsyncData *data)
|
||||
{
|
||||
if (data->info)
|
||||
g_object_unref (data->info);
|
||||
g_free (data->attributes);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
query_info_async_thread (GSimpleAsyncResult *res,
|
||||
GObject *object,
|
||||
GCancellable *cancellable)
|
||||
query_info_async_thread (GTask *task,
|
||||
gpointer source_object,
|
||||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
GFileOutputStream *stream = source_object;
|
||||
const char *attributes = task_data;
|
||||
GFileOutputStreamClass *class;
|
||||
GError *error = NULL;
|
||||
QueryInfoAsyncData *data;
|
||||
GFileInfo *info;
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (res);
|
||||
GFileInfo *info = NULL;
|
||||
|
||||
info = NULL;
|
||||
|
||||
class = G_FILE_OUTPUT_STREAM_GET_CLASS (object);
|
||||
class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
|
||||
if (class->query_info)
|
||||
info = class->query_info (G_FILE_OUTPUT_STREAM (object), data->attributes, cancellable, &error);
|
||||
info = class->query_info (stream, attributes, cancellable, &error);
|
||||
else
|
||||
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Stream doesn't support query_info"));
|
||||
|
||||
if (info == NULL)
|
||||
g_simple_async_result_take_error (res, error);
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
data->info = info;
|
||||
g_task_return_pointer (task, info, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -531,17 +516,14 @@ g_file_output_stream_real_query_info_async (GFileOutputStream *stream,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
QueryInfoAsyncData *data;
|
||||
GTask *task;
|
||||
|
||||
data = g_new0 (QueryInfoAsyncData, 1);
|
||||
data->attributes = g_strdup (attributes);
|
||||
task = g_task_new (stream, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, g_strdup (attributes), g_free);
|
||||
g_task_set_priority (task, io_priority);
|
||||
|
||||
res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_file_output_stream_real_query_info_async);
|
||||
g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)query_info_data_free);
|
||||
|
||||
g_simple_async_result_run_in_thread (res, query_info_async_thread, io_priority, cancellable);
|
||||
g_object_unref (res);
|
||||
g_task_run_in_thread (task, query_info_async_thread);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static GFileInfo *
|
||||
@ -549,17 +531,7 @@ g_file_output_stream_real_query_info_finish (GFileOutputStream *stream,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
||||
QueryInfoAsyncData *data;
|
||||
g_return_val_if_fail (g_task_is_valid (res, stream), NULL);
|
||||
|
||||
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_output_stream_real_query_info_async);
|
||||
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return NULL;
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
if (data->info)
|
||||
return g_object_ref (data->info);
|
||||
|
||||
return NULL;
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
@ -21,10 +21,10 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gicon.h"
|
||||
#include "gloadableicon.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
|
||||
@ -156,43 +156,35 @@ g_loadable_icon_load_finish (GLoadableIcon *icon,
|
||||
typedef struct {
|
||||
int size;
|
||||
char *type;
|
||||
GInputStream *stream;
|
||||
} LoadData;
|
||||
|
||||
static void
|
||||
load_data_free (LoadData *data)
|
||||
{
|
||||
if (data->stream)
|
||||
g_object_unref (data->stream);
|
||||
g_free (data->type);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
load_async_thread (GSimpleAsyncResult *res,
|
||||
GObject *object,
|
||||
GCancellable *cancellable)
|
||||
load_async_thread (GTask *task,
|
||||
gpointer source_object,
|
||||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
GLoadableIcon *icon = source_object;
|
||||
LoadData *data = task_data;
|
||||
GLoadableIconIface *iface;
|
||||
GInputStream *stream;
|
||||
LoadData *data;
|
||||
GError *error = NULL;
|
||||
char *type = NULL;
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (res);
|
||||
|
||||
iface = G_LOADABLE_ICON_GET_IFACE (object);
|
||||
stream = iface->load (G_LOADABLE_ICON (object), data->size, &type, cancellable, &error);
|
||||
iface = G_LOADABLE_ICON_GET_IFACE (icon);
|
||||
stream = iface->load (icon, data->size, &data->type,
|
||||
cancellable, &error);
|
||||
|
||||
if (stream == NULL)
|
||||
{
|
||||
g_simple_async_result_take_error (res, error);
|
||||
}
|
||||
if (stream)
|
||||
g_task_return_pointer (task, stream, g_object_unref);
|
||||
else
|
||||
{
|
||||
data->stream = stream;
|
||||
data->type = type;
|
||||
}
|
||||
g_task_return_error (task, error);
|
||||
}
|
||||
|
||||
|
||||
@ -204,14 +196,14 @@ g_loadable_icon_real_load_async (GLoadableIcon *icon,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
GTask *task;
|
||||
LoadData *data;
|
||||
|
||||
res = g_simple_async_result_new (G_OBJECT (icon), callback, user_data, g_loadable_icon_real_load_async);
|
||||
|
||||
task = g_task_new (icon, cancellable, callback, user_data);
|
||||
data = g_new0 (LoadData, 1);
|
||||
g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify) load_data_free);
|
||||
g_simple_async_result_run_in_thread (res, load_async_thread, 0, cancellable);
|
||||
g_object_unref (res);
|
||||
g_task_set_task_data (task, data, (GDestroyNotify) load_data_free);
|
||||
g_task_run_in_thread (task, load_async_thread);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static GInputStream *
|
||||
@ -220,21 +212,21 @@ g_loadable_icon_real_load_finish (GLoadableIcon *icon,
|
||||
char **type,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
||||
GTask *task;
|
||||
LoadData *data;
|
||||
GInputStream *stream;
|
||||
|
||||
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_loadable_icon_real_load_async);
|
||||
g_return_val_if_fail (g_task_is_valid (res, icon), NULL);
|
||||
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return NULL;
|
||||
task = G_TASK (res);
|
||||
data = g_task_get_task_data (task);
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
|
||||
if (type)
|
||||
stream = g_task_propagate_pointer (task, error);
|
||||
if (stream && type)
|
||||
{
|
||||
*type = data->type;
|
||||
data->type = NULL;
|
||||
}
|
||||
|
||||
return g_object_ref (data->stream);
|
||||
return stream;
|
||||
}
|
||||
|
105
gio/gmount.c
105
gio/gmount.c
@ -31,7 +31,7 @@
|
||||
#include "gmountprivate.h"
|
||||
#include "gthemedicon.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
*
|
||||
* Unmounting a #GMount instance is an asynchronous operation. For
|
||||
* more information about asynchronous operations, see #GAsyncResult
|
||||
* and #GSimpleAsyncResult. To unmount a #GMount instance, first call
|
||||
* and #GTask. To unmount a #GMount instance, first call
|
||||
* g_mount_unmount_with_operation() with (at least) the #GMount instance and a
|
||||
* #GAsyncReadyCallback. The callback will be fired when the
|
||||
* operation has resolved (either with success or failure), and a
|
||||
@ -386,14 +386,13 @@ g_mount_unmount (GMount *mount,
|
||||
|
||||
if (iface->unmount == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (mount),
|
||||
callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement unmount. */
|
||||
_("mount doesn't implement \"unmount\""));
|
||||
|
||||
g_task_report_new_error (mount, callback, user_data,
|
||||
g_mount_unmount_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement unmount. */
|
||||
_("mount doesn't implement \"unmount\""));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -426,6 +425,8 @@ g_mount_unmount_finish (GMount *mount,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_mount_unmount_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_MOUNT_GET_IFACE (mount);
|
||||
return (* iface->unmount_finish) (mount, result, error);
|
||||
@ -461,14 +462,13 @@ g_mount_eject (GMount *mount,
|
||||
|
||||
if (iface->eject == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (mount),
|
||||
callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement eject. */
|
||||
_("mount doesn't implement \"eject\""));
|
||||
|
||||
g_task_report_new_error (mount, callback, user_data,
|
||||
g_mount_eject_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement eject. */
|
||||
_("mount doesn't implement \"eject\""));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -501,6 +501,8 @@ g_mount_eject_finish (GMount *mount,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_mount_eject_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_MOUNT_GET_IFACE (mount);
|
||||
return (* iface->eject_finish) (mount, result, error);
|
||||
@ -538,14 +540,13 @@ g_mount_unmount_with_operation (GMount *mount,
|
||||
|
||||
if (iface->unmount == NULL && iface->unmount_with_operation == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (mount),
|
||||
callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement any of unmount or unmount_with_operation. */
|
||||
_("mount doesn't implement \"unmount\" or \"unmount_with_operation\""));
|
||||
|
||||
g_task_report_new_error (mount, callback, user_data,
|
||||
g_mount_unmount_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement any of unmount or unmount_with_operation. */
|
||||
_("mount doesn't implement \"unmount\" or \"unmount_with_operation\""));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -581,6 +582,8 @@ g_mount_unmount_with_operation_finish (GMount *mount,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_mount_unmount_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_MOUNT_GET_IFACE (mount);
|
||||
if (iface->unmount_with_operation_finish != NULL)
|
||||
@ -622,13 +625,13 @@ g_mount_eject_with_operation (GMount *mount,
|
||||
|
||||
if (iface->eject == NULL && iface->eject_with_operation == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (mount),
|
||||
callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement any of eject or eject_with_operation. */
|
||||
_("mount doesn't implement \"eject\" or \"eject_with_operation\""));
|
||||
g_task_report_new_error (mount, callback, user_data,
|
||||
g_mount_eject_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement any of eject or eject_with_operation. */
|
||||
_("mount doesn't implement \"eject\" or \"eject_with_operation\""));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -664,6 +667,8 @@ g_mount_eject_with_operation_finish (GMount *mount,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_mount_eject_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_MOUNT_GET_IFACE (mount);
|
||||
if (iface->eject_with_operation_finish != NULL)
|
||||
@ -708,14 +713,13 @@ g_mount_remount (GMount *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,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement remount. */
|
||||
_("mount doesn't implement \"remount\""));
|
||||
|
||||
g_task_report_new_error (mount, callback, user_data,
|
||||
g_mount_remount,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement remount. */
|
||||
_("mount doesn't implement \"remount\""));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -746,6 +750,8 @@ g_mount_remount_finish (GMount *mount,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_mount_remount))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_MOUNT_GET_IFACE (mount);
|
||||
return (* iface->remount_finish) (mount, result, error);
|
||||
@ -788,14 +794,13 @@ g_mount_guess_content_type (GMount *mount,
|
||||
|
||||
if (iface->guess_content_type == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (mount),
|
||||
callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement content type guessing. */
|
||||
_("mount doesn't implement content type guessing"));
|
||||
|
||||
g_task_report_new_error (mount, callback, user_data,
|
||||
g_mount_guess_content_type,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for mount objects that
|
||||
* don't implement content type guessing. */
|
||||
_("mount doesn't implement content type guessing"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -832,6 +837,8 @@ g_mount_guess_content_type_finish (GMount *mount,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return NULL;
|
||||
else if (g_async_result_is_tagged (result, g_mount_guess_content_type))
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
|
||||
iface = G_MOUNT_GET_IFACE (mount);
|
||||
return (* iface->guess_content_type_finish) (mount, result, error);
|
||||
|
121
gio/gunixmount.c
121
gio/gunixmount.c
@ -245,9 +245,6 @@ g_unix_mount_can_eject (GMount *mount)
|
||||
|
||||
typedef struct {
|
||||
GUnixMount *unix_mount;
|
||||
GAsyncReadyCallback callback;
|
||||
gpointer user_data;
|
||||
GCancellable *cancellable;
|
||||
int error_fd;
|
||||
GIOChannel *error_channel;
|
||||
GSource *error_channel_source;
|
||||
@ -255,35 +252,9 @@ typedef struct {
|
||||
gchar **argv;
|
||||
} UnmountEjectOp;
|
||||
|
||||
static void
|
||||
eject_unmount_cb (GPid pid, gint status, gpointer user_data)
|
||||
static void
|
||||
unmount_eject_op_free (UnmountEjectOp *data)
|
||||
{
|
||||
UnmountEjectOp *data = user_data;
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
if (WEXITSTATUS (status) != 0)
|
||||
{
|
||||
GError *error;
|
||||
error = g_error_new_literal (G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
data->error_string->str);
|
||||
simple = g_simple_async_result_new_from_error (G_OBJECT (data->unix_mount),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
error);
|
||||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
{
|
||||
simple = g_simple_async_result_new (G_OBJECT (data->unix_mount),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
NULL);
|
||||
}
|
||||
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
|
||||
if (data->error_channel_source)
|
||||
{
|
||||
g_source_destroy (data->error_channel_source);
|
||||
@ -293,21 +264,46 @@ eject_unmount_cb (GPid pid, gint status, gpointer user_data)
|
||||
g_string_free (data->error_string, TRUE);
|
||||
g_strfreev (data->argv);
|
||||
close (data->error_fd);
|
||||
g_spawn_close_pid (pid);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
eject_unmount_cb (GPid pid, gint status, gpointer user_data)
|
||||
{
|
||||
GTask *task = user_data;
|
||||
UnmountEjectOp *data = g_task_get_task_data (task);
|
||||
|
||||
if (g_task_return_error_if_cancelled (task))
|
||||
return;
|
||||
|
||||
g_spawn_close_pid (pid);
|
||||
|
||||
if (WEXITSTATUS (status) != 0)
|
||||
{
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"%s", data->error_string->str);
|
||||
}
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
eject_unmount_read_error (GIOChannel *channel,
|
||||
GIOCondition condition,
|
||||
gpointer user_data)
|
||||
GIOCondition condition,
|
||||
gpointer user_data)
|
||||
{
|
||||
UnmountEjectOp *data = user_data;
|
||||
GTask *task = user_data;
|
||||
UnmountEjectOp *data = g_task_get_task_data (task);
|
||||
char buf[BUFSIZ];
|
||||
gsize bytes_read;
|
||||
GError *error;
|
||||
GIOStatus status;
|
||||
|
||||
if (g_task_return_error_if_cancelled (task))
|
||||
return FALSE;
|
||||
|
||||
error = NULL;
|
||||
read:
|
||||
status = g_io_channel_read_chars (channel, buf, sizeof (buf), &bytes_read, &error);
|
||||
@ -341,11 +337,15 @@ read:
|
||||
static gboolean
|
||||
eject_unmount_do_cb (gpointer user_data)
|
||||
{
|
||||
UnmountEjectOp *data = (UnmountEjectOp *) user_data;
|
||||
GTask *task = user_data;
|
||||
UnmountEjectOp *data = g_task_get_task_data (task);
|
||||
GPid child_pid;
|
||||
GSource *child_watch;
|
||||
GError *error = NULL;
|
||||
|
||||
if (g_task_return_error_if_cancelled (task))
|
||||
return G_SOURCE_REMOVE;
|
||||
|
||||
if (!g_spawn_async_with_pipes (NULL, /* working dir */
|
||||
data->argv,
|
||||
NULL, /* envp */
|
||||
@ -369,34 +369,20 @@ eject_unmount_do_cb (gpointer user_data)
|
||||
goto handle_error;
|
||||
|
||||
data->error_channel_source = g_io_create_watch (data->error_channel, G_IO_IN);
|
||||
g_source_set_callback (data->error_channel_source,
|
||||
(GSourceFunc) eject_unmount_read_error, data, NULL);
|
||||
g_source_attach (data->error_channel_source, g_main_context_get_thread_default ());
|
||||
g_task_attach_source (task, data->error_channel_source,
|
||||
(GSourceFunc) eject_unmount_read_error);
|
||||
|
||||
child_watch = g_child_watch_source_new (child_pid);
|
||||
g_source_set_callback (child_watch, (GSourceFunc) eject_unmount_cb, data, NULL);
|
||||
g_source_attach (child_watch, g_main_context_get_thread_default ());
|
||||
g_task_attach_source (task, data->error_channel_source,
|
||||
(GSourceFunc) eject_unmount_cb);
|
||||
g_source_unref (child_watch);
|
||||
|
||||
handle_error:
|
||||
if (error != NULL) {
|
||||
GSimpleAsyncResult *simple;
|
||||
simple = g_simple_async_result_new_take_error (G_OBJECT (data->unix_mount),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
error);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
|
||||
if (data->error_string != NULL)
|
||||
g_string_free (data->error_string, TRUE);
|
||||
|
||||
if (data->error_channel != NULL)
|
||||
g_io_channel_unref (data->error_channel);
|
||||
|
||||
g_strfreev (data->argv);
|
||||
g_free (data);
|
||||
}
|
||||
if (error != NULL)
|
||||
{
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
@ -410,20 +396,23 @@ eject_unmount_do (GMount *mount,
|
||||
{
|
||||
GUnixMount *unix_mount = G_UNIX_MOUNT (mount);
|
||||
UnmountEjectOp *data;
|
||||
GTask *task;
|
||||
GSource *timeout;
|
||||
|
||||
data = g_new0 (UnmountEjectOp, 1);
|
||||
data->unix_mount = unix_mount;
|
||||
data->callback = callback;
|
||||
data->user_data = user_data;
|
||||
data->cancellable = cancellable;
|
||||
data->argv = g_strdupv (argv);
|
||||
|
||||
task = g_task_new (mount, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, data, (GDestroyNotify)unmount_eject_op_free);
|
||||
|
||||
if (unix_mount->volume_monitor != NULL)
|
||||
g_signal_emit_by_name (unix_mount->volume_monitor, "mount-pre-unmount", mount);
|
||||
|
||||
g_signal_emit_by_name (mount, "pre-unmount", 0);
|
||||
|
||||
g_timeout_add (500, (GSourceFunc) eject_unmount_do_cb, data);
|
||||
timeout = g_timeout_source_new (500);
|
||||
g_task_attach_source (task, timeout, (GSourceFunc) eject_unmount_do_cb);
|
||||
g_source_unref (timeout);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -449,7 +438,7 @@ g_unix_mount_unmount_finish (GMount *mount,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
return TRUE;
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -475,7 +464,7 @@ g_unix_mount_eject_finish (GMount *mount,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
return TRUE;
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "gthemedicon.h"
|
||||
#include "gvolume.h"
|
||||
#include "gvolumemonitor.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
/* for BUFSIZ */
|
||||
@ -270,9 +270,6 @@ _g_unix_volume_has_mount_path (GUnixVolume *volume,
|
||||
|
||||
typedef struct {
|
||||
GUnixVolume *unix_volume;
|
||||
GAsyncReadyCallback callback;
|
||||
gpointer user_data;
|
||||
GCancellable *cancellable;
|
||||
int error_fd;
|
||||
GIOChannel *error_channel;
|
||||
GSource *error_channel_source;
|
||||
@ -280,54 +277,53 @@ typedef struct {
|
||||
} EjectMountOp;
|
||||
|
||||
static void
|
||||
eject_mount_cb (GPid pid,
|
||||
gint status,
|
||||
gpointer user_data)
|
||||
eject_mount_op_free (EjectMountOp *data)
|
||||
{
|
||||
EjectMountOp *data = user_data;
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
if (WEXITSTATUS (status) != 0)
|
||||
{
|
||||
GError *error;
|
||||
error = g_error_new_literal (G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
data->error_string->str);
|
||||
simple = g_simple_async_result_new_from_error (G_OBJECT (data->unix_volume),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
error);
|
||||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
{
|
||||
simple = g_simple_async_result_new (G_OBJECT (data->unix_volume),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
NULL);
|
||||
}
|
||||
if (data->error_string != NULL)
|
||||
g_string_free (data->error_string, TRUE);
|
||||
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
if (data->error_channel != NULL)
|
||||
g_io_channel_unref (data->error_channel);
|
||||
|
||||
if (data->error_channel_source)
|
||||
{
|
||||
g_source_destroy (data->error_channel_source);
|
||||
g_source_unref (data->error_channel_source);
|
||||
}
|
||||
g_io_channel_unref (data->error_channel);
|
||||
g_string_free (data->error_string, TRUE);
|
||||
close (data->error_fd);
|
||||
g_spawn_close_pid (pid);
|
||||
|
||||
if (data->error_fd != -1)
|
||||
close (data->error_fd);
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
eject_mount_cb (GPid pid,
|
||||
gint status,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task = user_data;
|
||||
EjectMountOp *data = g_task_get_task_data (task);
|
||||
|
||||
if (WEXITSTATUS (status) != 0)
|
||||
{
|
||||
g_task_return_new_error (task,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
data->error_string->str);
|
||||
}
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
eject_mount_read_error (GIOChannel *channel,
|
||||
GIOCondition condition,
|
||||
gpointer user_data)
|
||||
{
|
||||
EjectMountOp *data = user_data;
|
||||
GTask *task = user_data;
|
||||
EjectMountOp *data = g_task_get_task_data (task);
|
||||
char buf[BUFSIZ];
|
||||
gsize bytes_read;
|
||||
GError *error;
|
||||
@ -371,6 +367,7 @@ eject_mount_do (GVolume *volume,
|
||||
char **argv)
|
||||
{
|
||||
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
|
||||
GTask *task;
|
||||
EjectMountOp *data;
|
||||
GPid child_pid;
|
||||
GSource *child_watch;
|
||||
@ -378,10 +375,11 @@ eject_mount_do (GVolume *volume,
|
||||
|
||||
data = g_new0 (EjectMountOp, 1);
|
||||
data->unix_volume = unix_volume;
|
||||
data->callback = callback;
|
||||
data->user_data = user_data;
|
||||
data->cancellable = cancellable;
|
||||
data->error_fd = -1;
|
||||
|
||||
task = g_task_new (unix_volume, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, data, (GDestroyNotify) eject_mount_op_free);
|
||||
|
||||
error = NULL;
|
||||
if (!g_spawn_async_with_pipes (NULL, /* working dir */
|
||||
argv,
|
||||
@ -407,33 +405,18 @@ eject_mount_do (GVolume *volume,
|
||||
goto handle_error;
|
||||
|
||||
data->error_channel_source = g_io_create_watch (data->error_channel, G_IO_IN);
|
||||
g_source_set_callback (data->error_channel_source,
|
||||
(GSourceFunc) eject_mount_read_error, data, NULL);
|
||||
g_source_attach (data->error_channel_source, g_main_context_get_thread_default ());
|
||||
g_task_attach_source (task, data->error_channel_source,
|
||||
(GSourceFunc) eject_mount_read_error);
|
||||
|
||||
child_watch = g_child_watch_source_new (child_pid);
|
||||
g_source_set_callback (child_watch, (GSourceFunc) eject_mount_cb, data, NULL);
|
||||
g_source_attach (child_watch, g_main_context_get_thread_default ());
|
||||
g_task_attach_source (task, child_watch, (GSourceFunc) eject_mount_cb);
|
||||
g_source_unref (child_watch);
|
||||
|
||||
handle_error:
|
||||
if (error != NULL)
|
||||
{
|
||||
GSimpleAsyncResult *simple;
|
||||
simple = g_simple_async_result_new_take_error (G_OBJECT (data->unix_volume),
|
||||
data->callback,
|
||||
data->user_data,
|
||||
error);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
|
||||
if (data->error_string != NULL)
|
||||
g_string_free (data->error_string, TRUE);
|
||||
|
||||
if (data->error_channel != NULL)
|
||||
g_io_channel_unref (data->error_channel);
|
||||
|
||||
g_free (data);
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "gvolume.h"
|
||||
#include "gthemedicon.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gsimpleasyncresult.h"
|
||||
#include "gtask.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
@ -42,9 +42,9 @@
|
||||
*
|
||||
* Mounting a #GVolume instance is an asynchronous operation. For more
|
||||
* information about asynchronous operations, see #GAsyncResult and
|
||||
* #GSimpleAsyncResult. To mount a #GVolume, first call
|
||||
* g_volume_mount() with (at least) the #GVolume instance, optionally
|
||||
* a #GMountOperation object and a #GAsyncReadyCallback.
|
||||
* #GTask. To mount a #GVolume, first call g_volume_mount() with (at
|
||||
* least) the #GVolume instance, optionally a #GMountOperation object
|
||||
* and a #GAsyncReadyCallback.
|
||||
*
|
||||
* Typically, one will only want to pass %NULL for the
|
||||
* #GMountOperation if automounting all volumes when a desktop session
|
||||
@ -359,10 +359,10 @@ g_volume_mount (GVolume *volume,
|
||||
|
||||
if (iface->mount_fn == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (volume), callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("volume doesn't implement mount"));
|
||||
|
||||
g_task_report_new_error (volume, callback, user_data,
|
||||
g_volume_mount,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("volume doesn't implement mount"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -397,6 +397,8 @@ g_volume_mount_finish (GVolume *volume,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_volume_mount))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_VOLUME_GET_IFACE (volume);
|
||||
return (* iface->mount_finish) (volume, result, error);
|
||||
@ -431,10 +433,10 @@ g_volume_eject (GVolume *volume,
|
||||
|
||||
if (iface->eject == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (volume), callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("volume doesn't implement eject"));
|
||||
|
||||
g_task_report_new_error (volume, callback, user_data,
|
||||
g_volume_eject_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("volume doesn't implement eject"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -466,6 +468,8 @@ g_volume_eject_finish (GVolume *volume,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
if (g_async_result_is_tagged (result, g_volume_eject_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_VOLUME_GET_IFACE (volume);
|
||||
return (* iface->eject_finish) (volume, result, error);
|
||||
@ -503,13 +507,13 @@ g_volume_eject_with_operation (GVolume *volume,
|
||||
|
||||
if (iface->eject == NULL && iface->eject_with_operation == NULL)
|
||||
{
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (volume),
|
||||
callback, user_data,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for volume objects that
|
||||
* don't implement any of eject or eject_with_operation. */
|
||||
_("volume doesn't implement eject or eject_with_operation"));
|
||||
g_task_report_new_error (volume, callback, user_data,
|
||||
g_volume_eject_with_operation,
|
||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
/* Translators: This is an error
|
||||
* message for volume objects that
|
||||
* don't implement any of eject or eject_with_operation. */
|
||||
_("volume doesn't implement eject or eject_with_operation"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -545,6 +549,8 @@ g_volume_eject_with_operation_finish (GVolume *volume,
|
||||
|
||||
if (g_async_result_legacy_propagate_error (result, error))
|
||||
return FALSE;
|
||||
else if (g_async_result_is_tagged (result, g_volume_eject_with_operation))
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
|
||||
iface = G_VOLUME_GET_IFACE (volume);
|
||||
if (iface->eject_with_operation_finish != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user