Fix usbredir being broken in 0.21 release

This commit is contained in:
Marc-André Lureau 2013-09-30 02:42:03 +02:00
parent 9e227d54bf
commit 3475a6aefe
8 changed files with 39 additions and 363 deletions

View File

@ -0,0 +1,30 @@
From 1c66070f5d59f27da876382aff55863ce7549db1 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Sun, 29 Sep 2013 22:59:32 +0200
Subject: [PATCH] spice-channel: Fix usbredir being broken since commit
159c6ebf
The usbredir channel uses spice_msg_in_raw to get its data, which uses
in->dpos to determine the msg size and that was no longer being set for
non sub-messages.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
gtk/spice-channel.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index b01b820..150636e 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1790,6 +1790,7 @@ void spice_channel_recv_msg(SpiceChannel *channel,
spice_channel_read(channel, in->data, msg_size);
if (c->has_error)
goto end;
+ in->dpos = msg_size;
msg_type = spice_header_get_msg_type(in->header, c->use_mini_header);
sub_list_offset = spice_header_get_msg_sub_list(in->header, c->use_mini_header);
--
1.8.3.1

View File

@ -1,45 +0,0 @@
From 3bb15dd43daaed6b1d77e66c59432f228935322e Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Thu, 11 Jul 2013 15:18:33 +0200
Subject: [spice-gtk] smartcard: Handle VCARD_EMUL_INIT_ALREADY_INITED
When initializing a software smartcard, vcard_emul_init() can
report success, error, or indicate that initialization has already
been done. In this last case, we would assume that an error occurred
instead of behaving as if the initialization succeeded.
vcard_emul_init() can end up being called multiple time if the
smartcard channel gets destroyed and recreated during the lifetime
of the application
Fixes rhbz#815639
---
gtk/smartcard-manager.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index 4b1efe2..2a0e397 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -408,6 +408,7 @@ static gboolean smartcard_manager_init(SpiceSession *session,
{
gchar *emul_args = NULL;
VCardEmulOptions *options = NULL;
+ VCardEmulError emul_init_status;
gchar *dbname = NULL;
GStrv certificates = NULL;
gboolean retval = FALSE;
@@ -448,7 +449,9 @@ static gboolean smartcard_manager_init(SpiceSession *session,
init:
SPICE_DEBUG("vcard_emul_init");
- if (vcard_emul_init(options) != VCARD_EMUL_OK) {
+ emul_init_status = vcard_emul_init(options);
+ if ((emul_init_status != VCARD_EMUL_OK)
+ && (emul_init_status != VCARD_EMUL_INIT_ALREADY_INITED)) {
*err = g_error_new(SPICE_CLIENT_ERROR,
SPICE_CLIENT_ERROR_FAILED,
"Failed to initialize smartcard");
--
1.8.3.1

View File

@ -1,130 +0,0 @@
From 28ef25781f62d6e3d96dba57a7ec772899b83661 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 24 Jun 2013 14:30:43 +0200
Subject: [PATCH] channel-main: Convert text line-endings if necessary
(rhbz#752350)
This implements line-ending conversion following the specification in the
commit message of spice-protocol commit 7be0e88e7e03a956b364cc847aad11b96ed4 :
vd_agent: Add caps for the agent to signal the guest line-ending (rhbz#752350)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit e45a446a9981ad4adaeff9c885962a8c6140333e)
---
gtk/channel-main.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 69 insertions(+), 4 deletions(-)
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index b58af52..b9e0da2 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1181,6 +1181,24 @@ static void agent_announce_caps(SpiceMainChannel *channel)
#define HAS_CLIPBOARD_SELECTION(c) \
VD_AGENT_HAS_CAPABILITY((c)->agent_caps, G_N_ELEMENTS((c)->agent_caps), VD_AGENT_CAP_CLIPBOARD_SELECTION)
+#define GUEST_LINEEND_LF(c) \
+ VD_AGENT_HAS_CAPABILITY((c)->agent_caps, G_N_ELEMENTS((c)->agent_caps), VD_AGENT_CAP_GUEST_LINEEND_LF)
+
+#define GUEST_LINEEND_CRLF(c) \
+ VD_AGENT_HAS_CAPABILITY((c)->agent_caps, G_N_ELEMENTS((c)->agent_caps), VD_AGENT_CAP_GUEST_LINEEND_CRLF)
+
+#ifdef G_OS_UNIX
+#define CLIENT_LINEEND_LF 1
+#else
+#define CLIENT_LINEEND_LF 0
+#endif
+
+#ifdef G_OS_WIN32
+#define CLIENT_LINEEND_CRLF 1
+#else
+#define CLIENT_LINEEND_CRLF 0
+#endif
+
/* any context: the message is not flushed immediately,
you can wakeup() the channel coroutine or send_msg_queue() */
static void agent_clipboard_grab(SpiceMainChannel *channel, guint selection,
@@ -1751,6 +1769,29 @@ static void file_xfer_handle_status(SpiceMainChannel *channel,
file_xfer_completed(task, error);
}
+/* any context */
+static guchar *convert_lineend(const guchar *in, gsize *size,
+ const gchar *from, const gchar *to)
+{
+ gchar *nul_terminated, **split, *out;
+
+ /* Nul-terminate */
+ nul_terminated = g_malloc(*size + 1);
+ memcpy(nul_terminated, in, *size);
+ nul_terminated[*size] = 0;
+
+ /* Convert */
+ split = g_strsplit(nul_terminated, from, -1);
+ out = g_strjoinv(to, split);
+ *size = strlen(out);
+
+ /* Clean-up */
+ g_strfreev(split);
+ g_free(nul_terminated);
+
+ return (guchar *)out;
+}
+
/* coroutine context */
static void main_agent_handle_msg(SpiceChannel *channel,
VDAgentMessage *msg, gpointer payload)
@@ -1809,12 +1850,22 @@ static void main_agent_handle_msg(SpiceChannel *channel,
case VD_AGENT_CLIPBOARD:
{
VDAgentClipboard *cb = payload;
+ guchar *data = cb->data;
+ gsize size = msg->size - sizeof(VDAgentClipboard);
+ if (cb->type == VD_AGENT_CLIPBOARD_UTF8_TEXT) {
+ if (GUEST_LINEEND_LF(c) && CLIENT_LINEEND_CRLF)
+ data = convert_lineend(data, &size, "\n", "\r\n");
+ if (GUEST_LINEEND_CRLF(c) && CLIENT_LINEEND_LF)
+ data = convert_lineend(data, &size, "\r\n", "\n");
+ }
emit_main_context(channel, SPICE_MAIN_CLIPBOARD_SELECTION, selection,
- cb->type, cb->data, msg->size - sizeof(VDAgentClipboard));
+ cb->type, data, size);
- if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
+ if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
emit_main_context(channel, SPICE_MAIN_CLIPBOARD,
- cb->type, cb->data, msg->size - sizeof(VDAgentClipboard));
+ cb->type, data, size);
+ if (data != cb->data)
+ g_free(data);
break;
}
case VD_AGENT_CLIPBOARD_GRAB:
@@ -2554,13 +2605,27 @@ void spice_main_clipboard_notify(SpiceMainChannel *channel,
* Since: 0.6
**/
void spice_main_clipboard_selection_notify(SpiceMainChannel *channel, guint selection,
- guint32 type, const guchar *data, size_t size)
+ guint32 type, const guchar *_data, size_t _size)
{
+ const guchar *data = _data;
+ gsize size = _size;
+
g_return_if_fail(channel != NULL);
g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
+ SpiceMainChannelPrivate *c = channel->priv;
+
+ if (type == VD_AGENT_CLIPBOARD_UTF8_TEXT) {
+ if (CLIENT_LINEEND_CRLF && GUEST_LINEEND_LF(c))
+ data = convert_lineend(data, &size, "\r\n", "\n");
+ if (CLIENT_LINEEND_LF && GUEST_LINEEND_CRLF(c))
+ data = convert_lineend(data, &size, "\n", "\r\n");
+ }
agent_clipboard_notify(channel, selection, type, data, size);
spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
+
+ if (data != _data)
+ g_free((guchar *)data);
}
/**

View File

@ -1,53 +0,0 @@
From 3010789e722f4a0fce62d7f172ad8134e1c5e866 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Tue, 6 Aug 2013 12:09:18 +0200
Subject: [spice-gtk] usb-widget: fix gtk2 Python bindings
The Python bindings generator failed to bind the USB widget, because of
the object/class declaration. The declaration was circumventing the
deprecated errors when compiling with GTK_DISABLE_DEPRECATED. We used
to need that because of broken gtk+ headers, but it is no longer
necessary since 15bd7ceba1434b5d710bfd16078044f30693467b.
(cherry picked from commit a7565265532f6abec0fd3c6d843683b58eee070a)
---
gtk/usb-device-widget.h | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/gtk/usb-device-widget.h b/gtk/usb-device-widget.h
index 3920990..b68cc6b 100644
--- a/gtk/usb-device-widget.h
+++ b/gtk/usb-device-widget.h
@@ -37,14 +37,6 @@ typedef struct _SpiceUsbDeviceWidget SpiceUsbDeviceWidget;
typedef struct _SpiceUsbDeviceWidgetClass SpiceUsbDeviceWidgetClass;
typedef struct _SpiceUsbDeviceWidgetPrivate SpiceUsbDeviceWidgetPrivate;
-#if GTK_CHECK_VERSION(3,0,0)
-typedef struct _GtkBox _SpiceGtkBox;
-typedef struct _GtkBoxClass _SpiceGtkBoxClass;
-#else
-typedef struct _GtkVBox _SpiceGtkBox;
-typedef struct _GtkVBoxClass _SpiceGtkBoxClass;
-#endif
-
/**
* SpiceUsbDeviceWidget:
*
@@ -52,7 +44,7 @@ typedef struct _GtkVBoxClass _SpiceGtkBoxClass;
*/
struct _SpiceUsbDeviceWidget
{
- _SpiceGtkBox parent;
+ GtkVBox parent;
/*< private >*/
SpiceUsbDeviceWidgetPrivate *priv;
@@ -67,7 +59,7 @@ struct _SpiceUsbDeviceWidget
*/
struct _SpiceUsbDeviceWidgetClass
{
- _SpiceGtkBoxClass parent_class;
+ GtkVBoxClass parent_class;
/* signals */
void (*connect_failed) (SpiceUsbDeviceWidget *widget,

View File

@ -1,27 +0,0 @@
From f5dfea28a3b909e51bcb544c399b02bd3ff65df7 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 19 Aug 2013 16:51:58 +0200
Subject: [PATCH spice-gtk] glib-compat: g_slist_free_full: pass the right ptr
to destroy (rhbz#997893)
The destroy function passed to g_slist_free_full should be passed the elements
data pointer, not the element itself.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
gtk/glib-compat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 21be1f6..c3bb8e6 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -88,7 +88,7 @@ g_slist_free_full(GSList *list,
if (free_func) {
for (el = list; el ; el = g_slist_next(el)) {
- free_func(el);
+ free_func(el->data);
}
}

View File

@ -1,53 +0,0 @@
From 630d4d0b2cddefa85aeab796b1859a9d65aaec5d Mon Sep 17 00:00:00 2001
From: Alon Levy <alevy@redhat.com>
Date: Wed, 28 Aug 2013 16:01:15 +0300
Subject: [PATCH 1/2] gtk/channel-cursor.c: add cursor_type_to_string for
debugging
---
gtk/channel-cursor.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index 99e7a48..41ad696 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -325,6 +325,23 @@ static void display_cursor_unref(display_cursor *cursor)
g_free(cursor);
}
+static const char *cursor_type_to_string(int type)
+{
+ switch (type) {
+ case SPICE_CURSOR_TYPE_MONO:
+ return "mono";
+ case SPICE_CURSOR_TYPE_ALPHA:
+ return "alpha";
+ case SPICE_CURSOR_TYPE_COLOR32:
+ return "color32";
+ case SPICE_CURSOR_TYPE_COLOR16:
+ return "color16";
+ case SPICE_CURSOR_TYPE_COLOR4:
+ return "color4";
+ }
+ return "unknown";
+}
+
static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
{
SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL(channel)->priv;
@@ -343,8 +360,9 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
if (scursor->flags & SPICE_CURSOR_FLAGS_NONE)
return NULL;
- CHANNEL_DEBUG(channel, "%s: type %d, %" PRIx64 ", %dx%d", __FUNCTION__,
- hdr->type, hdr->unique, hdr->width, hdr->height);
+ CHANNEL_DEBUG(channel, "%s: type %s(%d), %" PRIx64 ", %dx%d", __FUNCTION__,
+ cursor_type_to_string(hdr->type), hdr->type, hdr->unique,
+ hdr->width, hdr->height);
if (scursor->flags & SPICE_CURSOR_FLAGS_FROM_CACHE) {
item = cache_find(&c->cursors, hdr->unique);
--
1.8.3.1

View File

@ -1,50 +0,0 @@
From c4428fd886ca344fb77a684028e181236873b05e Mon Sep 17 00:00:00 2001
From: Alon Levy <alevy@redhat.com>
Date: Wed, 28 Aug 2013 16:14:16 +0300
Subject: [PATCH 2/2] gtk/channel-cursor: copy spicec hack, RHBZ #998529
flip -> unsupported by x11, since XCreatePixmapCursor has no invert
functionality, only a mask, shape, background and foreground colors. Use
this checkerboard hack to get some contrast for cursors in the guest
that relied on invert for the same contrast.
---
gtk/channel-cursor.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index 41ad696..e4a996b 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -259,11 +259,24 @@ static void mono_cursor(display_cursor *cursor, const guint8 *data)
for (x = 0; x < cursor->hdr.width; x++, dest += 4) {
if (and[x/8] & bit) {
if (xor[x/8] & bit) {
- /* flip -> hmm? */
- dest[0] = 0x00;
- dest[1] = 0x00;
- dest[2] = 0x00;
- dest[3] = 0x80;
+ /*
+ * flip -> unsupported by x11, since XCreatePixmapCursor has
+ * no invert functionality, only a mask, shape, background and
+ * foreground colors. Use this checkerboard hack to get some
+ * contrast for cursors in the guest that relied on invert for
+ * the same contrast.
+ */
+ if ((x ^ y) & 1) {
+ dest[0] = 0x30;
+ dest[1] = 0x30;
+ dest[2] = 0x30;
+ dest[3] = 0xc0;
+ } else {
+ dest[0] = 0x50;
+ dest[1] = 0x50;
+ dest[2] = 0x50;
+ dest[3] = 0x30;
+ }
} else {
/* unchanged -> transparent */
dest[0] = 0x00;
--
1.8.3.1

View File

@ -13,7 +13,7 @@
Name: spice-gtk
Version: 0.21
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A GTK+ widget for SPICE clients
Group: System Environment/Libraries
@ -21,6 +21,7 @@ License: LGPLv2+
URL: http://spice-space.org/page/Spice-Gtk
#VCS: git:git://anongit.freedesktop.org/spice/spice-gtk
Source0: http://www.spice-space.org/download/gtk/%{name}-%{version}%{?_version_suffix}.tar.bz2
Patch1: 0001-spice-channel-Fix-usbredir-being-broken-since-commit.patch
BuildRequires: intltool
BuildRequires: gtk2-devel >= 2.14
@ -146,10 +147,10 @@ if [ -n '%{?_version_suffix}' ]; then
mv spice-gtk-%{version}%{?_version_suffix} spice-gtk-%{version}
fi
#pushd spice-gtk-%{version}
#%patch1 -p1
#find . -name '*.stamp' | xargs touch
#popd
pushd spice-gtk-%{version}
%patch1 -p1
find . -name '*.stamp' | xargs touch
popd
%if %{with_gtk3}
cp -a spice-gtk-%{version} spice-gtk3-%{version}
@ -269,6 +270,9 @@ rm -rf %{buildroot}%{_datadir}/pkgconfig/spice-protocol.pc
%{_bindir}/spicy-stats
%changelog
* Mon Sep 30 2013 Marc-André Lureau <marcandre.lureau@redhat.com> - 0.21-2
- Fix usbredir being broken in 0.21 release
* Wed Sep 18 2013 Marc-André Lureau <marcandre.lureau@redhat.com> - 0.21-1
- Update to spice-gtk 0.21