Commit Graph

991 Commits

Author SHA1 Message Date
Marc-André Lureau
e3bb7b1cfd display: learn to restrict display to an area
Each spice widget can now restrict the area of the primary
surface they show and interact with by setting the private
area member.

A nice clean-up would be to seperate an area object that
would deal with clipping, input translation and color
conversion, but the resulting code would be similar anyway
2012-07-16 17:46:40 +02:00
Marc-André Lureau
59b7c8a005 widget: simplify redraw call 2012-07-16 17:46:40 +02:00
Marc-André Lureau
175f80a876 Update spice-common 2012-07-16 17:46:37 +02:00
Uri Lublin
f054f70270 usb-device-manager: mingw: connect: cleanup device if it's libdev is missing
For Windows client, when connecting a device to the guest, if a libusb
device (libdev) does not exist, cleanup and forget about that device.

Most likely, the device was plugged out at driver installation
time, and its remove-device event was ignored.
2012-07-16 10:25:06 +03:00
Yonit Halperin
9414fccffe migration/channel-inputs: reset motion count after migration
The motion count must stay synchronized with the server, otherwise,
it is possible that we will stop sending motion events to the server
after migration.

rhbz#835997
2012-07-12 14:54:25 +03:00
Uri Lublin
ac5a5b2c6a usb-device-manager: do not try to connect a usb device that was removed
If a device that is asked to be shared with the guest, is unplugged out
of the machine before being redirected, then let the user know that
usbredir of that device failed (and cleanup nicely).

For Windows client, the time between request and redir is larger, as
it includes the time it takes to install the libusb driver.
2012-07-11 17:41:09 +03:00
Marc-André Lureau
f16520755d usbutil: be more explicit about usbids_vendor_count usage
I introduced a regression in the previous patch, counting the
usbids_vendor_count from -1 if the previous attempt failed.
2012-07-11 16:29:34 +02:00
Marc-André Lureau
748b42ecc4 usbutil: fix crash on windows
vendor_count is the last access index, the actually count is +1.

On Windows, it crashes later on because of corrupted memory.

Thanks to valgrind for this precious help:

==4535== Invalid write of size 2
==4535==    at 0x40197E: spice_usbutil_parse_usbids (usbutil.c:170)
==4535==    by 0x401CEC: spice_usbutil_load_usbids (usbutil.c:241)
==4535==    by 0x4020C6: main (usbutil.c:322)
==4535==  Address 0x56b740c is 12 bytes after a block of size 348,160 alloc'd
==4535==    at 0x4A0884D: malloc (vg_replace_malloc.c:263)
==4535==    by 0x4EAAEBE: g_malloc (gmem.c:159)
==4535==    by 0x401847: spice_usbutil_parse_usbids (usbutil.c:156)
==4535==    by 0x401CEC: spice_usbutil_load_usbids (usbutil.c:241)
==4535==    by 0x4020C6: main (usbutil.c:322)
==4535==
2012-07-11 14:44:33 +02:00
Marc-André Lureau
2a54f19a64 usbutil: look up usb.ids under g_get_system_data_dirs() by default
Simplify a little bit the portability by looking up usb.ids file
under g_get_system_data_dirs(). This is how most resources are
found under other OS, looking up files under various places, since
installation location may vary.
2012-07-11 13:43:59 +02:00
Marc-André Lureau
b569d6ff7a build: fix make distcheck 2012-07-10 20:53:53 +02:00
Uri Lublin
12b348a163 usb-device-manager: mingw: win driver install callback: add missing ifdef
This fixes the following compilation error message (without USE_USBREDIR):

usb-device-manager.c:183:13: error: 'spice_usb_device_manager_drv_install_cb' declared 'static' but never defined [-Werror=unused-function]
2012-07-10 19:26:46 +03:00
Uri Lublin
59f31ce502 win-usb-driver-install: initialize "req" with memset
This fixes the following compilation error message:

../../gtk/win-usb-driver-install.c: In function 'spice_win_usb_driver_send_request':
../../gtk/win-usb-driver-install.c:187:5: error: missing braces around initializer [-Werror=missing-braces]
../../gtk/win-usb-driver-install.c:187:5: error: (near initialization for 'req.hdr') [-Werror=missing-braces]
2012-07-10 19:26:29 +03:00
Uri Lublin
00cbbf53af usb-device-manager: mingw: ignore "remove" udev event when un/installing a driver 2012-07-10 17:09:00 +03:00
Uri Lublin
62e9488868 usb-device-manager: mingw: keep driver install/uninstall state of a device
Currently only driver install/unsinstall is of interest, such that
extra udev events can be ignored.
2012-07-10 17:09:00 +03:00
Uri Lublin
fb6eb40ab4 usb-device-manager: add 'state' field to SpiceUsbDeviceInfo
To be used on Win32 to ignore extra udev events
received during driver install/uninstall.
2012-07-10 17:09:00 +03:00
Uri Lublin
e26f4bffa4 Win32/mingw: win-usb-dev: skip hubs
also skip devices with bad (0) device-address.
2012-07-10 17:09:00 +03:00
Uri Lublin
6b806a6e1e Win32/mingw: usb-device-manager: uninstall win usb driver upon device disconnect 2012-07-10 17:09:00 +03:00
Uri Lublin
147c0d1bb2 win-usb-driver-install: add capability to remove (uninstall) a win usb driver 2012-07-10 17:09:00 +03:00
Uri Lublin
714def3df0 Windows mingw: usb: Dynamically install a libusb driver for USB devices
- Added win-usb-driver-install.[ch]
- Added win-usb-clerk.h

Operation (on Windows, spice-gtk point of view):
- After some sanity checks, just before redir'ing a USB device
  a libusb driver needs to be installed (before libusb can open the device)
- A connection (NamedPipe) is established with usb-clerk, a libusb
  driver installation service, and a request for driver installation
  is sent.
- Installation status is asynchronously read from the pipe, and
  spice_usb_drv_install_finished() is called.
- Upon a successful intallation, usbredir continues.

Linux operation is not changed.
2012-07-10 17:09:00 +03:00
Arnon Gilboa
5525ce9734 Windows mingw: usb: implement GUdevDevice & GUdevClient for windows
- Added win-usb-dev.[ch]
- Added GUdevDevice and GUdevClient like classes
- Added uevent signal based on WM_DEVICECHANGE
2012-07-10 17:08:59 +03:00
Uri Lublin
cb68b670bb Make SpiceUsbDevice a box for SpiceUsbDeviceInfo, instead of a box for libusb_device
Note that this change may affect performance a bit, as sometimes there is
a need to find the libusb_device or the SpiceUsbDevice. Likely it's negligible.
2012-07-10 17:08:59 +03:00
Uri Lublin
4c1202f994 Introduce SpiceUsbDeviceInfo to be kept instead of a libusb_device
For Windows, it's better not to keep references for libusb_devices
that are not used.
So instead of makeing SpiceUsbDevice a box for a libusb_device
it is going to be a box for a SpiceUsbDeviceInfo.
2012-07-10 17:08:59 +03:00
Uri Lublin
42216eb7de Windows mingw: usb: configure.ac: do not require GUDEV for USBREDIR
For windows GUDEV is not required
For Linux GUDEV is checked as a part of USBREDIR block, but
as a separate check.
2012-07-10 17:08:59 +03:00
Uri Lublin
f871ed2176 usb-device-manager: mingw: add_dev: ignore already known devices
Sometimes on a Windows client, udev events are received while
the driver is being un/installed. so just ignore it
2012-07-10 17:08:59 +03:00
Uri Lublin
235e878181 usb-device-manager: add a helper function to find a usb device <bus, addr>
And use it in spice_usb_device_manager_remove_dev
2012-07-10 17:08:59 +03:00
Uri Lublin
0ba45213b0 spice_usb_device_get_description: use device-descriptor only to get <vid,pid>
In preparation for a different SpiceUsbDevice.

With the new SpiceUsbDeviceInfo, <vid,pid> will be provided by
SpiceUsbDevice, and not by the device_descriptor (from libusb)
2012-07-10 17:08:59 +03:00
Uri Lublin
15b4e7890f spice_usb_device_manager_device_error: replace SpiceUsbDevice with libusb_device
Its only user is channel-usbredir, which needs the libusb_device.

In preparations for a different SpiceUsbDevice.
2012-07-10 17:08:59 +03:00
Uri Lublin
c1799ead7e spice_usb_device_manager_auto_connect_cb: 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
97740e38e6 spice_usb_device_manager_add_dev: use type SpiceUsbDevice for "device"
Currently SpiceUsbDevice is a BOX for libusb_device.
In preparation for a different SpiceUsbDevice.

Renamed the libusb_device variable to libdev. Needed when
asking usbredir to check the filter.
2012-07-10 17:08:59 +03:00
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