Commit Graph

183 Commits

Author SHA1 Message Date
Uri Lublin
dd53b1766e vdagent::handle_max_clipboard fix vd_printf format
Using unsigned long to print a size_t.
2014-12-30 17:17:24 +02:00
Uri Lublin
8a28f878b9 vdagent: as_user: reorder initialization to make mingw-gcc happy
Fixes compiler warning that starts with:

In file included from vdagent/as_user.cpp:19:0:
vdagent/as_user.h: In constructor 'AsUser::AsUser(DWORD)':
vdagent/as_user.h:35:10: warning: 'AsUser::_started' will be initialized after [-Wreorder]
     bool _started;
2014-12-30 17:17:24 +02:00
Uri Lublin
eb276f4b45 Fix compiler warning (missing backslash in FileXfer::handle_start)
Visual Studio complains:
vdagent\file_xfer.cpp(85) : warning C4129: '%' : unrecognized character escape sequence

Replace "%s\%s" with "%s\\%s"
2014-12-30 17:16:53 +02:00
Cody Chan
6c070843cb Fix g_key_get_string() failure when string contains '['
In vd_agent/file_xfer.cpp is implemented a simple g_key_get_string,
but  when dragging a file with a name containing '[' (like te[st.txt),
it will fail.
From source code,
>next_group_pos = strstr(group_pos + strlen(group_pfx), "[");
>    if (next_group_pos && key_pos > next_group_pos) return false;
we know that it tries to find the end of current group by '[' label,
if we drag a file named te[st.txt, the key_string will be like:
[vdagent-file-xfer]
name=te[st.txt
size=10
so, it will fail when meta parsing and returns the
VD_AGENT_FILE_XFER_STATUS_ERROR message.

Here's the elegant method Christophe proposed and test ok, thanks to
him again!
2014-11-13 16:52:19 +01:00
Cody Chan
21b79679c1 Fix dragging of files with CJK characters in name
I submitted a patch several months ago about this issue,
here http://lists.freedesktop.org/archives/spice-devel/2014-February/016158.html
I check it again, and find that the value of
g_key_file_to_data(keyfile,...) is always utf-8, for the value of
g_uri_list_extract_uris() is utf8 urlencode.

So the display problem is caused by vd_agent, but how it displays
depends on the language of system, the following two screenshots show
the difference:

http://int64ago-tmp.qiniudn.com/guest-Chinese.png
http://int64ago-tmp.qiniudn.com/guest-English.png
2014-11-13 16:52:18 +01:00
Marc-André Lureau
6d1c038a8c Don't refresh displays config when updating
wnd_proc() is called during ChangeDisplaySettings(), when handling
monitors config. However, calling get_displays() will overwrite the
desired config.

So, while updating from 1 to 4 enabled monitors, when the 2nd monitor
config is enabled, the current config is read, and overwrite the rest of
the config, so first time only 2nd monitor is enabled, second time, 3rd
monitor etc.

https://bugzilla.redhat.com/show_bug.cgi?id=1111144
2014-06-19 19:15:39 +02:00
Marc-André Lureau
8588daa1e0 Learn to build spice-vdagent MSI installer 2014-06-19 15:27:31 +02:00
Uri Lublin
4171d11bb6 vdagent: clipboard: Add VD_AGENT_CAP_MAX_CLIPBOARD support
Do not send clipboard data bigger than last received
VDAgentMaxClipboard.

If a larger amount of data needs to be transferred between client and guest,
a different mechanism should be used, not clipboard.

The spice-protocol git-submodule is updated to include VD_AGENT_MAX_CLIPBOARD
and related definitions.
2014-03-09 18:55:42 +02:00
Uri Lublin
aed39aeccf vdagent: clipboard: GlobalUnlock on handle_request failure
Moved clipboard definition to the beginning of the function, as
mingw-gcc complains about gotos that jump over definitions.
2014-03-09 18:55:40 +02:00
Uri Lublin
efea0d654b Makefile.am: add INCLUDES to AM_CPPFLAGS
Fixes the following autoreconf (automake) warning:
Makefile.am:6: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
2013-11-13 10:40:17 +02:00
Uri Lublin
0a90473848 Makefile.am: tabify 2013-11-13 10:40:09 +02:00
Uri Lublin
4335b0d43a vdagent: file_xfer: make g_key_get_string safer
By providing the size of the destination string buffer.
2013-11-13 10:39:57 +02:00
Uri Lublin
066f614cee vdagent: file-xfer: make user desktop the target directory
Before, the target directory was a public one (for all users),
as file creation was not done with user privileges.

Now that the file is created with user privileges, it's
better to make the user desktop the target directory.
2013-11-13 10:39:47 +02:00
Uri Lublin
71193f6581 file_xfer: create file with user privileges 2013-11-13 10:39:37 +02:00
Uri Lublin
750a8bab40 vdagent: add as_user to run tasks with user privileges
The class calls Impersonate upon begin(), and Revert
upon end() or destruction.

The user is the current user that is logged in.

 create mode 100644 vdagent/as_user.cpp
 create mode 100644 vdagent/as_user.h
2013-11-13 10:24:59 +02:00
Christophe Fergeau
fac9e8d3bf Update NEWS for 0.7.2 release 2013-08-26 14:16:56 +02:00
Marc-André Lureau
4b9e9b1d28 Remove usage of more _s functions
Even before this change, it should have handled error conditions. We'd
be better off allocating those strings and failing on io op later on.
2013-07-17 21:20:47 +02:00
Marc-André Lureau
ad61eec961 Fix cast BOOL->PVOID warning
vdagent/display_setting.cpp:469:50: warning: cast to pointer from
integer of different size [-Wint-to-pointer-cast]
     if (!SystemParametersInfo(action, 0, (PVOID)param, 0)) {
2013-07-17 20:52:17 +02:00
Marc-André Lureau
fc1de85b49 Fix wrong size_t printf format
vdagent/desktop_layout.cpp:121:763: warning: format '%u' expects
argument of type 'unsigned int', but argument 8 has type
'std::vector<DisplayMode*>::size_type {aka long long unsigned int}'
[-Wformat=]
2013-07-17 20:49:19 +02:00
Marc-André Lureau
492ee05a6b Replace sscanf_s by sscanf
The _s functions need a recent msvcrt version, not shipped in XP by
default.

Furthermore, it appears that their sscanf_s usage was missing the extra
buffer size argument.
2013-07-17 20:45:22 +02:00
Marc-André Lureau
5129f33899 Add suggested parentheses
vdagent/vdagent.cpp: In member function 'void
VDAgent::on_clipboard_grab()':
vdagent/vdagent.cpp:951:52: warning: suggest parentheses around
assignment used as truth value [-Wparentheses]
2013-07-17 20:45:22 +02:00
Marc-André Lureau
b9d6baec2d Fix task could be used uninitialized 2013-07-17 20:45:21 +02:00
Marc-André Lureau
462295d9f8 Fix invalid print format for uint64_t values
format '%lu' expects argument of type 'long unsigned int', but argument
9 has type 'uint64_t
2013-07-17 20:45:21 +02:00
Marc-André Lureau
b52c9ddfa8 Fix wrong DWORD print fmt
format '%u' expects argument of type 'unsigned int', but argument 8 has type 'DWORD
2013-07-17 20:45:21 +02:00
Marc-André Lureau
3bf46bc2b2 dos2unix 2013-07-17 20:45:21 +02:00
Marc-André Lureau
846a787c9f Update spice-protocol 2013-07-17 20:45:17 +02:00
Arnon Gilboa
c751e8fda0 vdagent: add support for client -> guest file transfers
rhbz#956146
2013-06-27 14:23:49 +03:00
Arnon Gilboa
f7968d5035 cleanup dispatch_message() 2013-06-27 13:24:21 +03:00
Arnon Gilboa
631c8623e3 vdagent: advertise CRLF line-ending
rhbz#872252
2013-06-20 17:36:17 +03:00
Christophe Fergeau
859882c24b Update spice-protocol submodule to 0.12.5
This is needed to get the definition of VD_AGENT_CLIENT_DISCONNECTED
2013-05-14 12:42:24 +02:00
Uri Lublin
08a23eb45b vdagent: protect against NULL entry in _displays
rhbz#958051

It may be that a _displays entry will be NULL.
I encountered it when running with multiple QXL devices, for one of
which the driver failed to load since it was "out of resources".

Iterations over _displays should handle that case.
We found four such iterations, and fixed them in this patch.
2013-05-12 12:43:25 +03:00
Arnon Gilboa
b72b943309 vdagent: drop clipboard received after timeout
rhbz #951618
2013-05-09 14:19:11 +03:00
Arnon Gilboa
e55103589a vdagent: add support for VD_AGENT_CLIENT_DISCONNECTED
vdagent is stopped, so a new instance is to be launched by vdservice.
imho, this seems simpler than cleaning agent in/out msg state and
reseting the vio-serial device to cleanup pending msgs.

rhbz #956133
2013-05-09 14:19:11 +03:00
Arnon Gilboa
877ee81f81 vdagent: support sparse monitors config
rhbz #953973
2013-05-09 14:19:11 +03:00
Marc-André Lureau
4ca71770f2 build-sys: fix mingw build 2013-04-24 14:21:50 +02:00
Marc-André Lureau
de672f8cf2 Revert "Refresh monitor config only when needed"
This reverts commit 67c1bcf493.

Also add a comment why the refresh is necessary there. The original
issue, reentering call, doesn't seem reproducible...

https://bugzilla.redhat.com/show_bug.cgi?id=912793
2013-04-24 12:02:23 +03:00
Marc-André Lureau
8628ca2e09 Try harder to enable monitors
0ba6e2936 was trying to fix CreateDC() failing when the monitor is
disabled, unfortunately, enabling monitor with an arbitrary resolution
may still fail (the previous resolution, or the current one).

This patch address the issue by first trying the current resolution, and
falling back to a well-known resolution. This causes a temporary client
resolution change (bad), which is immediately adjusted to the arbitrary
resolution.

We may want to improve agent->driver communication of arbitrary
resolution before the driver is loaded, perhaps using registry or via
the spice server. Any of these solution will unfortunately take some more
time which we are missing.

https://bugzilla.redhat.com/show_bug.cgi?id=922394

(seem to solve related bugs, like mouse offset, or flashing monitors)
2013-04-24 12:00:18 +03:00
Arnon Gilboa
661e18fcf4 vdservice: add quotes to service path
for the case path contains a space, see CreateService() doc:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682450.aspx

rhbz #918635
2013-04-22 11:17:42 +03:00
Arnon Gilboa
0074ebcfb1 Revert "vdagent: add vdagent_helper to support mouse when UAC dialog takes focus"
This reverts commit dd9d1f41ca.
2013-04-22 11:17:40 +03:00
Arnon Gilboa
dd9d1f41ca vdagent: add vdagent_helper to support mouse when UAC dialog takes focus
Running the helper with ShellExecute(..."runas"...) is the way to SendInput()
to the UAC dialog in Windows Vista and above.

http://stackoverflow.com/questions/2426594/starting-a-uac-elevated-process-
from-a-non-interactive-service-win32-net-power

http://www.microsoft-questions.com/microsoft/Platform-SDK-Security/29620442/
how-to-proper-use-sendinput-to-a-elevated-window-from-a-service.aspx

rhbz #908422
2013-03-18 15:38:20 +02:00
Arnon Gilboa
136c8d3c94 vdagent: don't terminate if stop event cannot be opened
so vdagent can keep running as standalone without dependency on vdservice.

Regression was due to commit c1807e.

rhbz #903379
2013-03-18 14:13:04 +02:00
Arnon Gilboa
e364fa7799 vdagent: log unsupported grabbed clipboard formats
rhbz #919451 debugging, useful anyway
2013-03-18 13:21:14 +02:00
Arnon Gilboa
482a4980f4 vdagent: for Win7 class, use ClipboardFormatListener api
(Win7 class includes Win8/Vista/Server2012/Server2008/R2)

This new api was introduced in Vista/2K8 to keep track of clipboard changes,
without the need to trust the (mis)behavior of other applications registered
to the clipboard.

If the issue is reproduced on XP as well, it can be hacked by a periodic call
to ChangeClipboardChain & SetClipboardViewer as described in
http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/
521183dc-7872-472e-8104-8c0d75b1bf53

rhbz #919451
2013-03-18 13:16:22 +02:00
Arnon Gilboa
877e52386e vdservice: extract supported_system_version() to vdcommon
rhbz #919451 preparation
2013-03-18 12:54:04 +02:00
Arnon Gilboa
9b05b948fc vdagent: on encoding only, use HBITMAP to keep the correct palette
for decoding, keep using CF_DIB and CxImage.CopyToHandle() as before.

Regression was due to commit da07ce (rhbz #919150)

rhbz #921980
2013-03-18 12:45:25 +02:00
Marc-André Lureau
0ba6e29363 Reattach monitors
Teach vdagent to attach monitors. A monitor needs to be enabled before
we can set the custom resolution. Fortunately, the client doesn't seem
to have time to catch that, so things are smooth.

This is require to allow the virt-viewer display menu to work properly
and enable extra monitors: https://bugzilla.redhat.com/show_bug.cgi?id=919530
2013-03-16 01:02:47 +01:00
Marc-André Lureau
67c1bcf493 Refresh monitor config only when needed
Somehow wnd_proc()->get_display() may be reentered during ChangeDisplaySettings
2013-03-16 00:55:15 +01:00
Arnon Gilboa
da07ced71c vdagent: use HBITMAP instead of DIB for image encoding
CxImage DIB to PNG encoding seems to ignore pallete in some scenarios.
This issue happens when copying a png from FireFox, but with IE it's ok.

rhbz #919150
2013-03-12 13:09:50 +02:00
Arnon Gilboa
c1807e8040 vdservice: reset vdagent stop event after wait
vdagent terminates when the global event is set by vdservice. vdservice is also
responsible to reset the event in any case, without trusting vdagent to do so.
Otherwise, it may terminate the following vdagent instance immediately as well.

Regression was due to commit 2d03cc.

rhbz #868254
2013-02-26 17:58:44 +02:00
Christophe Fergeau
0399b98158 spec: Automatically substitute version
This commit generates a .spec file with the right version number
when configure is run.
2013-02-15 20:06:32 +01:00