Commit Graph

224 Commits

Author SHA1 Message Date
Benjamin Höglinger-Stelzer
d7405ee085 Fixed issue with multiple GPUs causing mouse to not work (see https://www.spinics.net/lists/spice-devel/msg42936.html) 2024-08-30 01:07:55 +02:00
Frediano Ziglio
5017510709 Add support for additional buttons (side and extra)
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-11-08 08:00:45 +00:00
Frediano Ziglio
fbcbd9a10c Remove warning compiling
Remove an alignment warning

vdagent/vdagent.cpp: In member function 'bool VDAgent::handle_announce_capabilities(const VDAgentAnnounceCapabilities*, uint32_t)':
vdagent/vdagent.cpp:1048:48: warning: taking address of packed member of 'VDAgentAnnounceCapabilities' may result in an unaligned pointer value [-Waddress-of-packed-member]
 1048 |     _client_caps.assign(announce_capabilities->caps, announce_capabilities->caps + caps_size);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~^~~~

Not a real issue, just annoying.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-06-16 10:23:24 +01:00
Jakub Janků
630da73bf8 clipboard: enable copying files from client using webdav
When the user wants to copy files, new spice-gtk can share those
files using the existing phodav server. In that case, it advertises
the VD_AGENT_CLIPBOARD_FILE_LIST type in the clipboard grab message.

Upon request of the clipboard data in the mentioned type, spice-gtk
provides a list of absolute paths in the phodav server - these are
the files that are supposed to be copied/moved.

The role of the vdagent is to adjust this data given the drive
letter of the mapped webdav share.

Files can be both copied and moved, although move was tested
only with Windows' File Explorer.

Copying files from the vdagnet side to the client is not
supported yet.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-07-31 12:48:28 +01:00
Frediano Ziglio
6fea9f59a7 desktop_layout: Update container iteration syntax
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-07-03 16:51:03 +01:00
Frediano Ziglio
ab6a4a0e18 Move set_display_depth from VDAgent to DesktopLayout
The function only change DesktopLayout.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-07-03 16:51:02 +01:00
Frediano Ziglio
645aadd34d Minor style update
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-07-03 16:50:56 +01:00
Frediano Ziglio
65e8edcf97 desktop_layout: Ignore Citrix Workspace displays
Citrix Workspace add 8 additional displays for off-line usage.
Ignore them like for mirrored displays.

This fixes https://gitlab.freedesktop.org/spice/win32/vd_agent/-/issues/8.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-15 12:23:54 +01:00
Frediano Ziglio
c76999df28 desktop_layout: Factor out a function to enumerate displays
Reduce code duplication, the enumeration happens 3 times.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-15 12:23:48 +01:00
Frediano Ziglio
d8d23f36a2 display_configuration: Update log strings
For other strings resolution is reported as "WxH", no spaces
around "x".

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-05-29 11:22:50 +01:00
Frediano Ziglio
2d6bcd9181 file_xfer: Return detailed error for invalid filename
A literal constant is used for error type as the project is not
dependent on glib2 and that Visual Studio and CMake are supported
so it would make the compilation on some environment more complicated
than actually is just for a constant.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-05-25 15:29:49 +01:00
Frediano Ziglio
d9aeb42bce desktop_layout: Use MutexLocker for lock/unlock
Reduce code and avoids to forget to unlock() in the future.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
2020-05-22 19:34:00 +01:00
Frediano Ziglio
fa2e3371c8 vdagent: Reset properly state of pending large messages upon disconnection
If the client closes the connection while having pending large messages
(split into multiple chunks) the state is not correctly reset causing
next client messages to be not correctly handled.

This can occur for instance if the client is closed (or killed) while
transferring a large file.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1548419.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-05-15 15:22:52 +01:00
Frediano Ziglio
0fe97cc05a Use final capabilities to check client messages
The client is sending messages that are compatible with agent
capabilities but also encoded with capabilities it knows of so to
check them we need to consider final capabilities, not client ones.

This fixes a regression introduced with
"vdagent: Reuse agent_check_message" where some messages were wrongly
interpreted as wrong (particularly some clipboard messages).

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Jakub Janků <jjanku@redhat.com>
2020-05-15 11:50:08 +01:00
Frediano Ziglio
9de1492446 vdagent: Reuse agent_check_message
That function does also more checks on the message.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jakub Janků <jjanku@redhat.com>
2020-04-28 16:50:13 +01:00
Frediano Ziglio
dd05463f9b Use SPICE_N_ELEMENTS instead of a constant for file_path size
Allows to easily change the size if needed

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 11:22:37 +01:00
Frediano Ziglio
b4776f4291 file_xfer: Return detailed error for no space
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 10:33:34 +01:00
Frediano Ziglio
ab3353b579 vdagent: Return better error if locked
Use specific VD_AGENT_FILE_XFER_STATUS_SESSION_LOCKED error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 10:33:34 +01:00
Frediano Ziglio
a914784295 vdagent: Allow to return detailed message for file transfer
Reuse AgentFileXferStatusMessageFull and agent_prepare_filexfer_status

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 10:33:34 +01:00
Frediano Ziglio
5988f86a75 Revert 3 last patches
Revert "try to remove other bugs", commit
57266085b9.
Revert "try to fix previous", commit
8e40377068.
Revert "attempt to fix more warnings!", commit
66b6933a38.

I put by mistake on the MR due to some automatic scripts.
Their state are pretty experimental.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-30 15:11:22 +01:00
Frediano Ziglio
57266085b9 try to remove other bugs 2020-03-23 14:13:48 +00:00
Frediano Ziglio
8e40377068 try to fix previous 2020-03-23 13:57:06 +00:00
Frediano Ziglio
66b6933a38 attempt to fix more warnings! 2020-03-23 13:38:40 +00:00
Frediano Ziglio
c8fd498b7f display_setting: Remove a warning
Avoids:

warning C4267: 'initializing': conversion from 'size_t' to 'DWORD', possible loss of data

Value won't never be that huge to cause overflow (we are reading a string
in a static buffer, we don't expect an encyclopedia).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-23 12:36:59 +00:00
Frediano Ziglio
f920c23e2e file_xfer: Remove a warning
Avoids:

warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-23 12:36:55 +00:00
Frediano Ziglio
0ad43eed50 Constification, does not make sense to change the messages processing them
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-01-10 12:56:25 +00:00
Frediano Ziglio
725141836a Remove Visual Studio project files
These project files were not correctly tested and updated for a
while.
Now that CMake is present it can be used to generate proper
updated Visual Studio projects instead.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-11 10:03:42 +00:00
Uri Lublin
1da442ad73 file-xfer: handle_start: use snprintf instead of sprintf_s
When building with older mingw, sprintf_s does not
always work as expected, but snprintf does.

Also it's more consistent in the file.

Note that when building with VS, snprintf becomes sprintf_s

Related: rhbz#1410181

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-06 09:42:39 +00:00
Frediano Ziglio
1dd3f3586a Add a test for filter_url function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-18 10:30:14 +00:00
Frediano Ziglio
9207d821d2 file_xfer: Open Download directory after a file transfer is finished
Have the same behaviour of Linux machines.
The directory is not opened again and again, only is not already
opened.
This is done checking the directory opened in explorer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-18 10:30:14 +00:00
Frediano Ziglio
8064ae397a file_xfer: Save files in Downloads directory
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-07 16:13:52 +00:00
Frediano Ziglio
5fbeb1af4e file_xfer: Separate code to get download directory location
Allows to reuse code to get download directory.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-07 16:12:35 +00:00
Frediano Ziglio
7a7c3b22e2 display_configuration: Define WINVER to avoid some declaration
Some declarations are available in MingW only defining a more recent
version of WINVER. Set WINVER to 0x0601 (Windows 7) to enable these
definitions.
This allows to clean some files.
The definition were already available in Fedora 22.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-06 09:24:30 +00:00
Yuri Benditovich
93f3aee7b4 make display disconnection persistent
https://bugzilla.redhat.com/show_bug.cgi?id=1477191
Currently on Win10 when one of multiple displays is
disconnected by the client, the qxl-wddm-dod driver
does not receive any update, the system just stops using
this adapter for rendering. As a result, the 'disconnected'
state of the adapter is not saved anywhere. On further
connect the client side recognize the adapter as active
and opens window for it. Current commit fixes the problem
by sending QXL_ESCAPE_MONITOR_CONFIG with zero area
to disabled adapter.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-08 11:43:16 +00:00
Yuri Benditovich
12a8f08f32 introduce turn_monitor_off method of WDDM interface
Adding method 'turn_monitor_off' to WDDM interface.
It sends QXL_ESCAPE_MONITOR_CONFIG escape with zeroed
display size to qxl-wddm-dod driver.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-08 11:43:16 +00:00
Yuri Benditovich
6e159118b2 construct WDDMMonitorConfigEscape also with NULL DisplayMode
Adding possibility to construct WDDMMonitorConfigEscape object
with NULL parameter of DisplayMode. In this case all the fields
depending on DisplayMode are set to zero.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-08 11:40:57 +00:00
Jonathon Jongsma
8bbb89e92b Don't exit when receiving unknown messages
In 8251fa25, a check on the minimum size of a message was introduced.
For unsupported messages, the vdagent simply exited. This makes it
inconsistent with previous behavior and inconsistent with the behavior
of the linux vdagent.  Instead, just print a warning indicating that an
unsupported message was received and ignore it.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-05 13:50:08 +00:00
Frediano Ziglio
5f0f3b590a Fix indentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-02-27 17:06:53 +00:00
谢 昆明
f264f5dec8 Fix typo, change DeviceName to device_name
Signed-off-by: kunming.xie <kunming.xie@hotmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-11-17 12:06:26 +00:00
Frediano Ziglio
348f7ed0cd Use GetModuleHandle to get some functions from user32 library
The library is surely already loaded as providing clipboard and
other utilities we need.
user32 is one of the main win32 libraries.
Avoid using LoadLibrary that increment the reference so we don't
need to call FreeLibrary to cleanly decrement the reference.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 12:20:49 +01:00
Frediano Ziglio
9264c7f367 vdagent: Add a comment around WinSta0_DesktopSwitch event usage
Multiple times while I was reading this code was not clear why the
synchronization of this event was not done in the main event loop.
Also document why we want to use it not relying just on
WTSRegisterSessionNotification and WM_WTSSESSION_CHANGE.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 12:07:27 +01:00
Frediano Ziglio
7038aa83b3 vdagent: Stop correctly helper thread
The thread launched to detect desktop switches events is not stopped
correctly causing potentially dandling pointers.
Queue a APC to make the loop exit and wait for thread termination
from the main thread.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:47:20 +01:00
Frediano Ziglio
2ae3bd5b9c Use destructor instead of cleanup function
More C++ style.
Also avoids missing cleanup calls.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:07:01 +01:00
Frediano Ziglio
0ac9d687e9 Introduce an helper to close VirtIo device
Do not assume we allocated the handle doing the cleanup.
This utility will be reused in next patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:05:50 +01:00
Frediano Ziglio
6d1d4241ac Use proper invalid value for _vio_serial
For some reason kernel handles in Windows have 2 invalid values
depending on the type. Files/devices use INVALID_HANDLE_VALUE (-1),
while others use NULL (0). As _vio_serial is a file, created
with CreateFile, use INVALID_HANDLE_VALUE for consistency.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-18 11:05:05 +01:00
Frediano Ziglio
55290d1766 Avoids to call supported_system_version()
The only reason we call this function is to check if the
system should support some APIs.
Instead just check directly if these APIs are supported
calling GetProcAddress directly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 18:35:31 +01:00
Frediano Ziglio
e9421d09b8 Avoid declaring _system_version member
The check can be done a single time, no reason to cache
supported_system_version() value.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 16:38:04 +01:00
Frediano Ziglio
c0a6e42e80 Avoid declaring event_thread_id
As the value is never used we can pass NULL in CreateThread.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:50:36 +01:00
Frediano Ziglio
6a0683707f Allocate _control_event and _stop_event just once
Handle _control_event and _stop_event destruction in destructor.
Allows to call VDAgent::run multiple time if needed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:25:42 +01:00
Frediano Ziglio
7b368a134f Allow one more character reading strings from registry
The strings in the registry are usually NUL-terminated but this
is not a requirement.
Handle the case when the string, considering the terminator, fit
into the reading buffer. In this case accept the string. In the
case the string fit into the buffer but is not terminated
returns ERROR_MORE_DATA (the error that would be returned if the
string didn't fit in the buffer as there is no place to add the
terminator).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:12:33 +01:00