summaryrefslogtreecommitdiffstats
path: root/src/win-usb-driver-install.c
diff options
context:
space:
mode:
authorFabiano Fidêncio <fidencio@redhat.com>2016-03-23 03:50:40 +0100
committerFabiano Fidêncio <fidencio@redhat.com>2016-03-23 04:22:37 +0100
commit0fa5895d6218269cce31315c36cb588c72a52fe0 (patch)
treec814ae20419b8c9715c93971d1a69f84aa0837eb /src/win-usb-driver-install.c
parentf973df7e54b296f5cd2eca7498aea285a84ab007 (diff)
downloadspice-gtk-wip/gtask-helper.tar.gz
spice-gtk-wip/gtask-helper.tar.xz
spice-gtk-wip/gtask-helper.zip
Introduce gtask-helper.[ch]wip/gtask-helper
As noticed, GTask's heurestic for return a task in idle or immediately doesn't work when using Coroutine and that's okay, we just need to do the idle ourself. And in order to avoid code duplication, let's introduce and make usage of the new g_task_helper_return_* functions. These functions match exactly with the existing g_task_return_* functions and the only difference is that they return on idle instead of returning immediately. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Diffstat (limited to 'src/win-usb-driver-install.c')
-rw-r--r--src/win-usb-driver-install.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/win-usb-driver-install.c b/src/win-usb-driver-install.c
index 0d4627a..92aad38 100644
--- a/src/win-usb-driver-install.c
+++ b/src/win-usb-driver-install.c
@@ -31,6 +31,7 @@
#include <gio/gio.h>
#include <gio/gwin32inputstream.h>
#include <gio/gwin32outputstream.h>
+#include "gtask-helper.h"
#include "spice-util.h"
#include "win-usb-clerk.h"
#include "win-usb-driver-install.h"
@@ -143,13 +144,13 @@ void win_usb_driver_handle_reply_cb(GObject *gobject,
if (err) {
g_warning("failed to read reply from usbclerk (%s)", err->message);
- g_task_return_error(priv->task, err);
+ g_task_helper_return_error(priv->task, err);
goto failed_reply;
}
if (bytes == 0) {
g_warning("unexpected EOF from usbclerk");
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_WIN_USB_DRIVER_ERROR,
SPICE_WIN_USB_DRIVER_ERROR_FAILED,
"unexpected EOF from usbclerk");
@@ -166,7 +167,7 @@ void win_usb_driver_handle_reply_cb(GObject *gobject,
if (priv->reply.hdr.magic != USB_CLERK_MAGIC) {
g_warning("usbclerk magic mismatch: mine=0x%04x server=0x%04x",
USB_CLERK_MAGIC, priv->reply.hdr.magic);
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_WIN_USB_DRIVER_ERROR,
SPICE_WIN_USB_DRIVER_ERROR_MESSAGE,
"usbclerk magic mismatch");
@@ -176,7 +177,7 @@ void win_usb_driver_handle_reply_cb(GObject *gobject,
if (priv->reply.hdr.version != USB_CLERK_VERSION) {
g_warning("usbclerk version mismatch: mine=0x%04x server=0x%04x",
USB_CLERK_VERSION, priv->reply.hdr.version);
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_WIN_USB_DRIVER_ERROR,
SPICE_WIN_USB_DRIVER_ERROR_MESSAGE,
"usbclerk version mismatch");
@@ -185,7 +186,7 @@ void win_usb_driver_handle_reply_cb(GObject *gobject,
if (priv->reply.hdr.type != USB_CLERK_REPLY) {
g_warning("usbclerk message with unexpected type %d",
priv->reply.hdr.type);
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_WIN_USB_DRIVER_ERROR,
SPICE_WIN_USB_DRIVER_ERROR_MESSAGE,
"usbclerk message with unexpected type");
@@ -195,7 +196,7 @@ void win_usb_driver_handle_reply_cb(GObject *gobject,
if (priv->reply.hdr.size != bytes) {
g_warning("usbclerk message size mismatch: read %"G_GSSIZE_FORMAT" bytes hdr.size=%d",
bytes, priv->reply.hdr.size);
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_WIN_USB_DRIVER_ERROR,
SPICE_WIN_USB_DRIVER_ERROR_MESSAGE,
"usbclerk message with unexpected size");
@@ -203,14 +204,14 @@ void win_usb_driver_handle_reply_cb(GObject *gobject,
}
if (priv->reply.status == 0) {
- g_task_return_new_error(priv->task,
+ g_task_helper_return_new_error(priv->task,
SPICE_WIN_USB_DRIVER_ERROR,
SPICE_WIN_USB_DRIVER_ERROR_MESSAGE,
"usbclerk error reply");
goto failed_reply;
}
- g_task_return_boolean (priv->task, TRUE);
+ g_task_helper_return_boolean(priv->task, TRUE);
failed_reply:
g_clear_object(&priv->task);
@@ -312,7 +313,7 @@ void spice_win_usb_driver_op(SpiceWinUsbDriver *self,
if (priv->task) { /* allow one install/uninstall request at a time */
g_warning("Another request exists -- try later");
- g_task_return_new_error(task,
+ g_task_helper_return_new_error(task,
SPICE_WIN_USB_DRIVER_ERROR, SPICE_WIN_USB_DRIVER_ERROR_FAILED,
"Another request exists -- try later");
goto failed_request;
@@ -325,7 +326,7 @@ void spice_win_usb_driver_op(SpiceWinUsbDriver *self,
if (!spice_win_usb_driver_send_request(self, op_type,
vid, pid, &err)) {
g_warning("failed to send a request to usbclerk %s", err->message);
- g_task_return_error(task, err);
+ g_task_helper_return_error(task, err);
goto failed_request;
}