Commit 80494c4c authored by Christian Hergert's avatar Christian Hergert

transfers: port to IdeTask

parent e5a2751e
......@@ -25,6 +25,7 @@
#include "subprocess/ide-subprocess.h"
#include "subprocess/ide-subprocess-launcher.h"
#include "transfers/ide-pkcon-transfer.h"
#include "threading/ide-task.h"
struct _IdePkconTransfer
{
......@@ -62,17 +63,17 @@ ide_pkcon_transfer_wait_check_cb (GObject *object,
gpointer user_data)
{
IdeSubprocess *subprocess = (IdeSubprocess *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_assert (IDE_IS_SUBPROCESS (subprocess));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
if (!ide_subprocess_wait_check_finish (subprocess, result, &error))
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
}
static void
......@@ -120,7 +121,7 @@ ide_pkcon_transfer_execute_async (IdeTransfer *transfer,
g_autoptr(IdeSubprocessLauncher) launcher = NULL;
g_autoptr(IdeSubprocess) subprocess = NULL;
g_autoptr(GDataInputStream) data_stream = NULL;
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_autoptr(GError) error = NULL;
GInputStream *stdout_stream;
......@@ -129,12 +130,12 @@ ide_pkcon_transfer_execute_async (IdeTransfer *transfer,
g_assert (IDE_IS_TRANSFER (transfer));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_pkcon_transfer_execute_async);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_pkcon_transfer_execute_async);
if (self->packages == NULL || !self->packages[0])
{
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
IDE_EXIT;
}
......@@ -152,7 +153,7 @@ ide_pkcon_transfer_execute_async (IdeTransfer *transfer,
if (subprocess == NULL)
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
......@@ -183,9 +184,9 @@ ide_pkcon_transfer_execute_finish (IdeTransfer *transfer,
IDE_ENTRY;
g_assert (IDE_IS_TRANSFER (transfer));
g_assert (G_IS_TASK (result));
g_assert (IDE_IS_TASK (result));
ret = g_task_propagate_boolean (G_TASK (result), error);
ret = ide_task_propagate_boolean (IDE_TASK (result), error);
IDE_RETURN (ret);
}
......
......@@ -23,6 +23,7 @@
#include "transfers/ide-transfer.h"
#include "transfers/ide-transfer-manager.h"
#include "threading/ide-task.h"
struct _IdeTransferManager
{
......@@ -354,26 +355,26 @@ ide_transfer_manager_execute_cb (GObject *object,
{
IdeTransfer *transfer = (IdeTransfer *)object;
IdeTransferManager *self;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
IDE_ENTRY;
g_assert (IDE_IS_TRANSFER (transfer));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
self = g_task_get_source_object (task);
self = ide_task_get_source_object (task);
if (!ide_transfer_execute_finish (transfer, result, &error))
{
g_signal_emit (self, signals[TRANSFER_FAILED], 0, transfer, error);
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (notify_properties);
}
else
{
g_signal_emit (self, signals[TRANSFER_COMPLETED], 0, transfer);
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
}
if (!ide_transfer_manager_get_has_active (self))
......@@ -405,7 +406,7 @@ ide_transfer_manager_execute_async (IdeTransferManager *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IDE_ENTRY;
......@@ -413,8 +414,8 @@ ide_transfer_manager_execute_async (IdeTransferManager *self,
g_return_if_fail (IDE_IS_TRANSFER (transfer));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_transfer_manager_execute_async);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_transfer_manager_execute_async);
if (!ide_transfer_manager_append (self, transfer))
{
......@@ -440,7 +441,7 @@ ide_transfer_manager_execute_finish (IdeTransferManager *self,
GError **error)
{
g_return_val_if_fail (IDE_IS_TRANSFER_MANAGER (self), FALSE);
g_return_val_if_fail (G_IS_TASK (result), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
......@@ -21,6 +21,7 @@
#include "ide-debug.h"
#include "transfers/ide-transfer.h"
#include "threading/ide-task.h"
typedef struct
{
......@@ -54,13 +55,13 @@ ide_transfer_real_execute_async (IdeTransfer *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_assert (IDE_IS_TRANSFER (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_return_boolean (task, TRUE);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_return_boolean (task, TRUE);
}
static gboolean
......@@ -69,9 +70,9 @@ ide_transfer_real_execute_finish (IdeTransfer *self,
GError **error)
{
g_assert (IDE_IS_TRANSFER (self));
g_assert (G_IS_TASK (result));
g_assert (IDE_IS_TASK (result));
return g_task_propagate_boolean (G_TASK (result), error);
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
static void
......@@ -229,13 +230,13 @@ ide_transfer_execute_cb (GObject *object,
{
IdeTransfer *self = (IdeTransfer *)object;
IdeTransferPrivate *priv = ide_transfer_get_instance_private (self);
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
IDE_ENTRY;
g_assert (IDE_IS_TRANSFER (self));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
priv->active = FALSE;
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ACTIVE]);
......@@ -244,14 +245,14 @@ ide_transfer_execute_cb (GObject *object,
if (!IDE_TRANSFER_GET_CLASS (self)->execute_finish (self, result, &error))
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
priv->completed = TRUE;
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_COMPLETED]);
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
IDE_EXIT;
}
......@@ -263,7 +264,7 @@ ide_transfer_execute_async (IdeTransfer *self,
gpointer user_data)
{
IdeTransferPrivate *priv = ide_transfer_get_instance_private (self);
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IDE_ENTRY;
......@@ -275,8 +276,8 @@ ide_transfer_execute_async (IdeTransfer *self,
* cleanly from the subclass implementation. It also allows us to ensure
* that the subclasses execute_finish() is guaranteed to be called.
*/
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_transfer_execute_async);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_transfer_execute_async);
/*
* Wrap our own cancellable so that we can gracefully control
......@@ -317,9 +318,9 @@ ide_transfer_execute_finish (IdeTransfer *self,
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_TRANSFER (self), FALSE);
g_return_val_if_fail (G_IS_TASK (result), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
ret = g_task_propagate_boolean (G_TASK (result), error);
ret = ide_task_propagate_boolean (IDE_TASK (result), error);
IDE_RETURN (ret);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment