Commit Graph

962 Commits

Author SHA1 Message Date
Uri Lublin
a0ec25a170 spice_usb_device_manager_add_dev: check auto_ok before freeing libusb device list
In preparation for a different SpiceUsbDevice.
2012-07-10 17:08:59 +03:00
Uri Lublin
2339c0005c spice_usb_device_manager_remove_dev: use type SpiceUsbDevice for "device"
Currently SpiceUsbDevice is a BOX for libusb_device.
In preparation for a different SpiceUsbDevice.
2012-07-10 17:08:59 +03:00
Uri Lublin
ad61272563 controller/test.c: mingw: fix compiler bad param warning for ReadFile
It seems that ssize_t is int, while DWORD is long

Compiler warning (some whitespaces where added for readability):
  ../../../gtk/controller/test.c: In function 'read_from_pipe':
  ../../../gtk/controller/test.c:108:5: warning: passing argument 4 \
       of 'ReadFile' from incompatible pointer type [enabled by default]
  In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:70:0,
                   from ../../../gtk/controller/test.c:27:
  /usr/i686-w64-mingw32/sys-root/mingw/include/winbase.h:1426:29: note: expected \
       'LPDWORD' but argument is of type 'ssize_t *'
2012-07-10 17:08:59 +03:00
Uri Lublin
b22a0976f4 usb-device-manager: warn if a device to remove was not found
Also changed a bit the warning text on device-add to differentiate the two.
2012-07-10 17:08:59 +03:00
Uri Lublin
9edc788526 spicy: more informative presentation of usb devices in menu
Using the default format.
2012-07-10 17:08:59 +03:00
Marc-André Lureau
8a1643d651 controller: async flush read/write
Windows namedpipes behave a bit differently from Unix socket, and may
return incomplete read/write. By using 2 read/write() helpers, try to
complete the operation before returning. Since the IO operation may be
splitted over several call, we make sure the buffer pointer is on the
heap. We use exception for EOF or BROKEN_PIPE condition, which also
simplifies the code.

To really work with namedpipe, the giowin32streams need to be fixed as
well to handle concurrent read & write properly, see for details:
https://bugzilla.gnome.org/show_bug.cgi?id=679288
2012-07-10 13:08:34 +02:00
Marc-André Lureau
43d311c090 Remove mandatory generation of vala debug C
Use make VALAFLAGS=-g if you need it instead
2012-07-10 13:08:34 +02:00
Marc-André Lureau
c596896747 Fix mingw build
printf is redefined by glib/gi18n.h

In file included from ../spice-common/common/spice_common.h:29:0,
                 from ../spice-common/common/ring.h:23,
                 from spice-channel-cache.h:23,
                 from spice-session-priv.h:26,
                 from desktop-integration.c:29:
../spice-common/common/log.h:49:17: error: 'libintl_printf' is an unrecognized format function type [-Werror=format]
../spice-common/common/log.h:56:16: error: 'libintl_printf' is an unrecognized format function type [-Werror=format]
In file included from ../spice-common/common/canvas_base.h:25:0,
                 from decode.h:23,
                 from spice-session-priv.h:27,
                 from desktop-integration.c:29:
../spice-common/common/lz.h:22:5: error: 'libintl_printf' is an unrecognized format function type [-Werror=format]
../spice-common/common/lz.h:23:5: error: 'libintl_printf' is an unrecognized format function type [-Werror=format]
../spice-common/common/lz.h:24:5: error: 'libintl_printf' is an unrecognized format function type [-Werror=format]
2012-07-08 17:27:19 +02:00
Marc-André Lureau
266773c5fb unused variable 'self' if !USE_USB
CC     spice-widget-enums.lo
desktop-integration.c: In function 'spice_desktop_integration_dispose':
desktop-integration.c:175:30: error: unused variable 'self'
[-Werror=unused-variable]
2012-07-08 17:01:17 +02:00
Hans de Goede
2157ea0bf8 spice-widget: Don't change usbredir/automount settings while redirecting
The keyboard focus may change while usb-device-manager is in the process of
redirecting a usb-device (as this may show a policykit dialog). Making
autoredir/automount setting changes while this is happening is not a good idea!

Since usb-device-manager already sets keyboard_grab_inhibit when it is
redirecting to allow the policykit dialog to show, we can use that to
inhibit usb-autoredir setting changes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-07-06 09:27:42 +02:00
Hans de Goede
c64a959722 spice-gtk-session: hookup automount inhibiting
Inhibit automounting when usb-autoredirection is active.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-07-06 09:27:42 +02:00
Hans de Goede
633586ba64 Add a desktop-integration helper class
We need to integrate closely with the desktop environment of the user in
several cases. Some examples are disabling auto-mounting when auto-usbredir
is active (rhbz#812972), and disabling the screensaver when fullscreen
(fdo#34793).

Unfortuntely these kinds of things require desktop environment specific
handling. Therefor this patch introduces a desktop-integration helper class,
which is to server as a container for all sort of desktop environment specific
functions.

For now it just supports disabling automounting under Gnome, but this will be
extended in the future.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-07-06 09:27:42 +02:00
Yonit Halperin
7e8380414f agent: fix mishandling of SPICE_MSG_MAIN_AGENT_TOKEN
Add the given tokens instead of overriding the existing ones.
2012-06-28 11:04:42 +03:00
Hans de Goede
b5d4cc27c4 spice-gtk-session: rename update_keyboard_focus to request_auto_usbredir
To better reflect what then function does, also rename the tracking variable
inside spice-gtk-session to match.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-06-26 13:41:40 +02:00
Hans de Goede
567b41fdc3 spice-gtk-session: Fix keyboard focus tracking
This patch changes the "do we have focus?" tracking, to keeping a counter with
how many widgets have focus. The reason for this is that sometimes multiple
spice-widgets can have focus at the same time, yes really! Sometimes (rarely,
hard to reproduce) the focus in event for one window arrives before the
focus out of the other window.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-06-26 13:40:39 +02:00
Hans de Goede
cf168467be spice-gtk-session: Only update usb "auto-connect" when doing "auto-usb-redir"
Only update the UsbDeviceManager's "auto-connect" property when
"auto-usb-redir" is set, otherwise leave it as is. This allows apps to
control UsbDeviceManager's "auto-connect" directly, without it getting reset
on every keyboard focus change.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-06-26 10:23:12 +02:00
Uri Lublin
713f52e04d Move "err" variable definition to beginning of the function
This fixes the following compilation error:
channel-usbredir.c: In function 'spice_usbredir_channel_connect_device_async':
channel-usbredir.c:313:9: error: jump skips variable initialization [-Werror=jump-misses-init]
2012-06-24 16:51:13 +03:00
Christophe Fergeau
dc806d5b36 Fix build when usbredir is disabled
I broke it with my leak fixes
2012-06-13 14:39:09 +02:00
Christophe Fergeau
faa2599188 Fix various memory leaks
==25063== 12,827 (2,032 direct, 10,795 indirect) bytes in 127 blocks are definitely lost in loss record 9,477 of 9,502
==25063==    at 0x4A0884D: malloc (vg_replace_malloc.c:263)
==25063==    by 0x3DE384D2BE: g_malloc (gmem.c:159)
==25063==    by 0x3DE38616B1: g_slice_alloc (gslice.c:1003)
==25063==    by 0x3DE38346B0: g_error_new_valist (gerror.c:393)
==25063==    by 0x3DE3834A8C: g_set_error (gerror.c:560)
==25063==    by 0x3DE4871108: g_socket_receive_with_blocking (gsocket.c:2513)
==25063==    by 0x5B708E8: bio_gsocket_bread (bio-gsocket.c:56)
==25063==    by 0x61AEBD8: BIO_read (bio_lib.c:212)
==25063==    by 0x5ECAC5B: ssl3_read_n (s3_pkt.c:238)
==25063==    by 0x5ECBD3D: ssl3_read_bytes (s3_pkt.c:318)
==25063==    by 0x5ECD6CF: ssl3_get_message (s3_both.c:426)
==25063==    by 0x5EC5AFB: ssl3_get_new_session_ticket (s3_clnt.c:1822)

==25063== 90 bytes in 3 blocks are definitely lost in loss record 7,354 of 9,502
==25063==    at 0x4A0884D: malloc (vg_replace_malloc.c:263)
==25063==    by 0x3DE384D2BE: g_malloc (gmem.c:159)
==25063==    by 0x3DE3862D0B: g_strdup (gstrfuncs.c:356)
==25063==    by 0x5B961B5: spice_usb_device_manager_set_property (usb-device-manager.c:306)
==25063==    by 0x3DE40148FB: g_object_constructor (gobject.c:1352)
==25063==    by 0x3DE4015D70: g_object_newv (gobject.c:1713)
==25063==    by 0x3DE401655F: g_object_new_valist (gobject.c:1830)
==25063==    by 0x3DE485924D: g_initable_new_valist (ginitable.c:224)
==25063==    by 0x3DE4859348: g_initable_new (ginitable.c:148)
==25063==    by 0x5B97330: spice_usb_device_manager_get (usb-device-manager.c:770)
==25063==    by 0x52D8C6B: spice_gtk_session_update_keyboard_focus (spice-gtk-session.c:845)
==25063==    by 0x52D6DC1: spice_gtk_session_set_property (spice-gtk-session.c:238)

==25063== 120 bytes in 3 blocks are definitely lost in loss record 8,448 of 9,502
==25063==    at 0x4A06F18: calloc (vg_replace_malloc.c:566)
==25063==    by 0x68BB2E5: usbredirfilter_string_to_rules (usbredirfilter.c:54)
==25063==    by 0x5B96123: spice_usb_device_manager_set_property (usb-device-manager.c:293)
==25063==    by 0x3DE40148FB: g_object_constructor (gobject.c:1352)
==25063==    by 0x3DE4015D70: g_object_newv (gobject.c:1713)
==25063==    by 0x3DE401655F: g_object_new_valist (gobject.c:1830)
==25063==    by 0x3DE485924D: g_initable_new_valist (ginitable.c:224)
==25063==    by 0x3DE4859348: g_initable_new (ginitable.c:148)
==25063==    by 0x5B97330: spice_usb_device_manager_get (usb-device-manager.c:770)
==25063==    by 0x52D8C6B: spice_gtk_session_update_keyboard_focus (spice-gtk-session.c:845)
==25063==    by 0x52D6DC1: spice_gtk_session_set_property (spice-gtk-session.c:238)
==25063==    by 0x3DE40148FB: g_object_constructor (gobject.c:1352)

==25063== 11,959 (72 direct, 11,887 indirect) bytes in 1 blocks are definitely lost in loss record 9,475 of 9,502
==25063==    at 0x4A06F18: calloc (vg_replace_malloc.c:566)
==25063==    by 0x3459C92DDC: XkbGetKeyboardByName (XKBGetByName.c:59)
==25063==    by 0x52DF000: vnc_display_keymap_gdk2xtkbd_table (vncdisplaykeymap.c:153)
==25063==    by 0x52D9FA6: spice_display_init (spice-widget.c:389)
==25063==    by 0x3DE402FA05: g_type_create_instance (gtype.c:1892)
==25063==    by 0x3DE40147A7: g_object_constructor (gobject.c:1849)
==25063==    by 0x52DA07B: spice_display_constructor (spice-widget.c:412)
==25063==    by 0x3DE4015D70: g_object_newv (gobject.c:1713)
==25063==    by 0x3DE401655F: g_object_new_valist (gobject.c:1830)
==25063==    by 0x3DE4016893: g_object_new (gobject.c:1545)
==25063==    by 0x52DE746: spice_display_new (spice-widget.c:1924)
==25063==    by 0x41D6C3: virt_viewer_display_spice_new (virt-viewer-display-spice.c:219)
2012-06-13 12:53:51 +02:00
Marc-André Lureau
f15d0fdda1 misc: use g_value_dup_object 2012-06-11 18:11:22 +02:00
Marc-André Lureau
2f45d3656a Fix incorrect format string 2012-06-11 18:10:56 +02:00
Marc-André Lureau
a8842c3ae4 Fix video playback with GStreamer backend
The playback audio delay is not correctly adjusted, we should take
min_latency, set by gst_bin_do_latency_func ().
2012-06-11 18:10:56 +02:00
Marc-André Lureau
ea33f16130 Deprecate spice_channel_set_capability()
This was initially public to eventually let a derived class
implement more capabilities. Even though it is technically
doable to derive and tweak exisiting channels, there is a
lack of support in spice-gtk for doing that.
2012-06-11 18:10:48 +02:00
Marc-André Lureau
4b8d5813a8 Allow to disable specific capabilities at runtime
Capability BAR for channel FOO can be disabled at runtime by setting
the SPICE_FOO_CAP_BAR environment variable to '0'
Disabling capabilities is useful for testing purpose.
2012-06-11 18:08:56 +02:00
Christophe Fergeau
e463f252f1 spice_channel_coroutine: fix function exit in error path
spice_channel_coroutine returns a void *, but one of its error path
is doing 'return FALSE'. This commit replaces this return with a
'goto cleanup' since this is what is done in the other error paths.
2012-06-11 11:13:06 +02:00
Christophe Fergeau
b65b510ef8 spice_channel_coroutine: emit signals in all error cases
There are several very unlikely failures where no signal is emitted
to indicate the failure. Since applications rely on these signals
to detect spice-gtk connection failures, it's important to emit
one in all error cases.
2012-06-11 11:09:50 +02:00
Christophe Fergeau
5a36c87faa Emit SPICE_CHANNEL_ERROR_TLS when certificate can't be found
When trying to start remote-viewer with SPICE over TLS with
--spice-ca-file with a wrong filename, the connection fails
but remote-viewer keeps displaying the "Trying to connect"
message. The only hint that something went wrong is:
(remote-viewer:12924): GSpice-WARNING **: loading ca certs from a/home/teuf/foo.crt

This patch makes sure we emit a SPICE_CHANNEL_ERROR_TLS before
giving up on channel creation to inform the application that
an error happened.
2012-06-10 23:30:13 +02:00
Christophe Fergeau
331cba23cc build: allow building with newer glibc-headers and -O0
Fix copied from libvirt, commit by Eric Blake.

glibc 2.15 (on Fedora 17) coupled with explicit disabling of
optimization during development dies a painful death:

/usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]

Work around this by only conditionally defining _FORTIFY_SOURCE,
in the case where glibc can actually use it.  The trick is using
AH_VERBATIM instead of AC_DEFINE.
2012-06-07 17:23:05 +02:00
Marc-André Lureau
d55d7ee729 Update spice-common 2012-06-05 22:29:36 +02:00
Hans de Goede
885e4491fa spicy: Change 'OK' button to 'Close' button in USB device selection
The USB device selection applies immediately, so the dialog should be using
'Close' instead of 'OK' for its primary button.

This patch syncs spicy with virt-viewer wrt the USB device selection dialog.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-06-04 15:46:33 +02:00
Marc-André Lureau
ee5fc35078 widget: disconnect session_inhibit_keyboard_grab_changed
There is one handler we forgot to disconnect on dispose()
that may cause a crash.

I am thinking of generalizing usage of
spice_g_signal_connect_object()..

Should fix:
https://bugzilla.redhat.com/show_bug.cgi?id=823570
2012-05-29 15:31:46 +02:00
Marc-André Lureau
e47b78ec5a Clipboard clean-up and fixes for Windows client
The Windows client was getting in the way of guest copy-paste,
because when the guest was taking the clipboard grab, the agent
notifies the client, it takes the grab too, and in return
receives clipboard notification of new ownership from the client
clipboard.

Though we had a hack to check if this new client clipboard event
is caused by us, the Windows Gtk clipboard is giving 2 notifications
for some reasons.

It turned out there is a much better way than the "selfgrab" hack,
by setting ownership of the clipboard. Problem solved, and cleaner
code!

https://bugzilla.redhat.com/show_bug.cgi?id=822688
2012-05-28 16:19:54 +02:00
Marc-André Lureau
94d44c98a6 session: correctly track main channel
The main channel can change when we are reconnecting to the server,
for example, when querying the password to the user. From there,
the old main channel is destroyed, but we don't track properly the
new main channel.

This fix migration crashing later on, because of missing main channel:
https://bugzilla.redhat.com/show_bug.cgi?id=823874
2012-05-22 14:02:38 +02:00
Marc-André Lureau
4e419a1223 Reset grab-sequence on match
This avoids triggering the grab event on consecutive
matches, such as ctrl+alt (match) then ctrl+alt+foo
(match again) that would prevent the longer combination
from being sent.
2012-05-18 15:27:31 +02:00
Marc-André Lureau
a187824159 If grab sequence is matched, still send modifier keys
If the last key pressed from the grab sequence is a modifier
key, let send it to the guest too.

This solves the issue of default grab-sequence being ctrl+alt
and preventing ctrl+alt+del from working.
2012-05-18 15:25:20 +02:00
Marc-André Lureau
524277aab2 Running out of reserved space, break ABI
The change abc56811de actually added
a field in a public struct while changing overall struct size, the
fields were also reorder, all of this breaks ABI.

However, we are running out of free space in SpiceChannelClass
struct. And since the SPICE_RESERVED_PADDING was 44 bytes, that is
quite limited on 64bits (only 5 pointers fit).

I propose we break ABI during this cycle. This means that programs
using spice-gtk will need to be recompiled to use the new library.
(the old library should be parallel installable though). This let us:
- use a better SPICE_RESERVED_PADDING based on pointer size, since
  it is what is usually added for virtual methods
- reset the amount taken from the padding in the various struct
- reorder fields a little
- add some missing "priv" pointers
- whatever I am missing that we can still change before next release

Please comment if I am missing something, or correct me
2012-05-17 16:19:53 +02:00
Marc-André Lureau
dbde50a646 session: correctly set and unset ssl-verify flags
If no cert-subject or pubkey is provided, we should unset the corresponding flags.
2012-05-17 15:45:31 +02:00
Yonit Halperin
8603cc3e9e record channel: reseting channel caps 2012-05-17 15:53:54 +03:00
Yonit Halperin
cace46554b playback channel: reseting channel caps 2012-05-17 15:53:54 +03:00
Yonit Halperin
fb5f68b7ee display channel: reseting channel caps 2012-05-17 15:53:54 +03:00
Yonit Halperin
6c470ec40b main channel: reseting channel caps 2012-05-17 15:53:53 +03:00
Yonit Halperin
abc56811de Fix not setting channel specific capabilities upon channel reset
Related: rhbz#821795

The capabilities have been zeroed after channel reset, which have lead to
publish the wrong caps when both port and tls-port are given, and the
channels are secured (first attempt to connect the channel with "port"
has failed; the channel got reset, and then reconnected with "tls-port"
and bad caps). Specifically, the bug causes semi-seamless migration not
to work when part of the channels are secured.
2012-05-17 15:53:46 +03:00
Marc-André Lureau
bac3fd5ae1 python: fix Spice.Audio binding
The spice_audio_new() function is not correctly generated h2def.py
anymore because of the surrounding #ifdef and macros. Add it in
the manual.defs instead.

Avoid API breakage:
2012-05-10 01:56:48,884 (cli:83): Uncaught exception:
Traceback (most recent call last):
  File /usr/share/virt-manager/virtManager/console.py, line 475, in
_channel_new_cb
    self.audio = spice.Audio(self.spice_session)
TypeError: GObject.__init__() takes exactly 0 arguments (1 given)

https://bugzilla.redhat.com/show_bug.cgi?id=820335
2012-05-10 02:55:16 +02:00
Yonit Halperin
f84e039f25 display: video streaming: add support for frames of different sizes
rhbz #815426

When playing a youtube video on Windows guest, the driver sometimes sends
images which contain a video frame, but also other parts of the
screen (e.g., the you tube process bar). In order to prevent glitches, we send these
images as part of the stream, using SPICE_MSG_DISPLAY_STREAM_DATA_SIZED.
2012-05-03 12:13:06 +03:00
Marc-André Lureau
da0071300e Fix parsing URI query
Do not depend on uninitialized "len" variable to set the query string.

https://bugzilla.redhat.com/show_bug.cgi?id=818169
2012-05-02 14:03:13 +02:00
Christophe Fergeau
312b55a79c g_getenv returns a const string
When switching from getenv to g_getenv, 'doms' declaration
wasn't changed from char * to const char *, which causes
a gcc warning.
2012-04-27 15:13:12 +02:00
Daniel P. Berrange
dd6c260291 Fix annotations for GrabSequence class
The default transfer mode is wrong for spice_display_get_grab_keys.
The array parameter for spice_grab_sequence_new needs explicit
annotation

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-04-27 09:33:59 +01:00
Daniel P. Berrange
e82757283f Replace getenv/setenv with g_getenv/g_setenv for Win32 portability 2012-04-26 10:07:33 +01:00
Daniel P. Berrange
3073e240f3 Fix --spice-debug flag on glib >= 2.31
With glib >= 2.31 no debug messages are ever printed out by
default, which makes the --spice-debug flag useless. This
fix explicitly turns on the appropriate log domain when
debug is requested. It takes care to preserve the users
own existing log domain requests
2012-04-25 12:24:09 +01:00
Marc-André Lureau
45f5f3d47e Release v0.12 2012-04-24 13:10:23 +02:00