Commit Graph

910 Commits

Author SHA1 Message Date
Daniel P. Berrange
041a39f97f Avoid use of non-literal string with g_debug 2014-10-27 16:43:13 +00:00
Daniel P. Berrange
6b72c98cff Fix typo s/to to/to/ 2014-10-27 16:39:06 +00:00
Daniel P. Berrange
bd6fd964f9 Remove useless 'if (...)' before free()
The 'free()' function accepts NULL, so you should not
check for NULL before calling it.
2014-10-27 16:38:06 +00:00
Jonathon Jongsma
f0d662994f Don't try to re-configure displays when there are none
virt_viewer_session_on_monitor_geometry_changed() gets called
immediately upon agent connection, but sometimes this is before any
displays have been received. Simply return early when this is the case.
2014-10-27 10:37:31 -05:00
Jonathon Jongsma
8fa5e004ec Shift top-left display to origin
When using a custom fullscreen display configuration, it's possible to
specify that e.g. a single screen should be fullscreen on client
monitor #4. Since we send down absolute positions and disable alignment
when all windows are in fullscreen, we can send configurations with a
very large offset to the top-left corner. This could result in the guest
trying to create a screen that was much larger than necessary. For
example when sending a configuration of 1280x1024+4240+0, the guest
would need to allocate a screen of size 5520x1024, which might fail if
video memory was too low. To avoid this issue, we shift all displays
so that the minimum X coordinate for all screens is at x=0, and the
minimum y coordinate is at y=0.
2014-10-27 10:37:31 -05:00
Jonathon Jongsma
221d5f5cd4 Move monitor alignment function to util header 2014-10-24 09:14:09 -05:00
Christophe Fergeau
7bc8ceea38 man: Improve documentation for 'version' field in vv files 2014-10-23 13:47:11 +02:00
Rex Dieter
862dd22362 spec: Update/optimize mime scriptlets 2014-10-23 13:47:11 +02:00
Fabiano Fidêncio
ccc3fbe16a Check for the right spice version in session-spice.c
We have to check for the spice version where the
SPICE_CLIENT_ERROR_AUTH_NEEDS_PASSWORD_AND_USERNAME was introduced and
not for the one where spice_channel_get_error() was introduced.
2014-10-16 16:25:23 +02:00
Jonathon Jongsma
65560fa466 Don't disable "send key" menu when display isn't ready
The ability to send a keystroke should not depend on whether a display
is ready or not, it only depends on whether the display exists or not.

See https://bugzilla.redhat.com/show_bug.cgi?id=1152574
2014-10-16 16:09:25 +02:00
Jonathon Jongsma
c64a3c8f70 Fix bug with initial placement of fullscreen windows
The function app_window_try_fullscreen() will lookup the initial monitor
for the nth monitor internally, so we should pass in the display ID to the function
rather than the mapped monitor ID. This was causing 2 monitors on the
same monitor with a configuration like this:

    monitor-mapping=1:2;2:1
2014-10-15 23:48:50 +02:00
Fabiano Fidêncio
910ee34248 Force display_show_hint() when the display is set
Since a window is not created at startup for each display, the first
display(s) set when the application is opened will never receive and
treat the "notify::show-hint" signal on VirtViewerWindow, once the
callback is only set when the display is set to the specific window.
It causes problems like the "Send Key" menu not activated till an extra
display is added. To avoid this problem, let's force a call to
display_show_hint() everytime a display is set.

Resolves: rhbz#1152468
https://bugzilla.redhat.com/show_bug.cgi?id=1152468
2014-10-15 23:48:50 +02:00
Marc-André Lureau
3eaecbb3a4 Use socat instead of nc if possible
It turns out that nc does not leave on server disconnect, and there
doesn't seem to be any option to do that, leaving client open, and
a bunch of idle processes.

Replacing nc with socat solves that, client is disconnected when
the VM is shut down, when the sever connection is closed.

https://bugzilla.redhat.com/show_bug.cgi?id=1030487
2014-10-10 15:14:18 +02:00
Fabiano Fidêncio
9886055a4a Prefill the username in the authentication dialog
Lets prefill the username entry using the user name of the
current user.
2014-10-10 12:57:08 +02:00
Fabiano Fidêncio
69b3096f51 Use 'username' property from .vv file for spice-session 2014-10-10 12:57:08 +02:00
Fabiano Fidêncio
04e02148b2 Ask for username when connecting with SASL
When connecting with SASL for authentication, some authentication
mechanisms need a username (the plain text and md5 ones, for example).
2014-10-10 12:57:08 +02:00
Pavel Grunt
88f634179e Show VM chooser dialog when starting virt-viewer with no arg
When user starts virt-viewer without specifying VM domain name
or with a wrong name a list of running machines is shown
and user may choose one of them.
2014-10-10 12:57:08 +02:00
Pavel Grunt
7a47a4da08 Show VM chooser dialog when oVirt VM name is missing
When a user tries to connect to ovirt without specifying
VM name (remote-viewer ovirt://ovirt.example.com) or with
wrong VM name a list of available virtual machines is shown,
and the user may pick a machine he wants to connect to.
2014-10-10 12:57:08 +02:00
Christophe Fergeau
334169749e man: Document [ovirt] section in .vv files
Add documentation for these options even though they are mainly meant to
be set by the oVirt portal when it generates the .vv file.
2014-10-09 17:21:26 +02:00
Christophe Fergeau
53b347c92c man: Improve doc for 'ca' in .vv files
Make it clearer that this CA will be used to validate the certificate
presented by the remote SPICE host when using TLS.
2014-10-09 17:21:26 +02:00
Christophe Fergeau
d2fb85642a Fix 'seperate' typo in man page/comments 2014-10-09 17:21:26 +02:00
Christophe Fergeau
9803f9cb42 ovirt: Allow to remove CD images
It turns out this is supposed to be done through update requests with a
CD image with an empty name, which is what the current code tries to do.
The only reason it's not working is because of server-side bugs with
oVirt < 3.5
The requirement on libgovirt is raised to 0.3.2 as
a small change is needed as well in libgovirt to allow empty filenames:
https://git.gnome.org/browse/libgovirt/commit/?id=bdb788fcc

Without this change, nothing too bad will happen, but the CD won't be
removed and warnings will be logged in the console.
2014-10-09 17:19:12 +02:00
Ján Tomko
bb44ce0a1f Prefer virDomainOpenGraphicsFD for --attach
The virDomainOpenGraphics API cannot label the socket
we pass to it. Prefer virDomainOpenGraphicsFD (if building
with libvirt 1.2.8 or later) which creates the socket for us
and works with SELinux too.

Fall back to the old API if the new one is unsupported
(i.e. the libvirtd on the host is older than the libvirt version
virt-viewer was compiled against).

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-10-01 18:58:13 +02:00
Fabiano Fidêncio
ec5a661469 Let the user cancel the SPICE auth dialog
virt_viewer_auth_collect_credentials() was recently changed to return
a boolean instead of an integer (2561c171). This change introduced a
regression in the authentication dialog behavior, making it impossible
for the user to cancel.
2014-09-26 16:30:43 +02:00
Fabiano Fidêncio
141d69b7f5 Improve authentication error messages
Adding a better error message to our default error message, based on the
libvirt error. Also, the libvirt error is shown as debug.

https://bugzilla.redhat.com/show_bug.cgi?id=1142742
2014-09-26 16:30:43 +02:00
Fabiano Fidêncio
42ffe6f8b4 Simplify virt_viewer_auth_libvirt_credentials() return value logic
As the function should return < 0 in error cases, let's explicitly
return/set the return value to -1 in error cases. Otherwise, the
function will return 0.

This patch also fixes a regression introduced by (a5ce2ed3).

https://bugzilla.redhat.com/show_bug.cgi?id=1142742
2014-09-26 16:30:43 +02:00
Jonathon Jongsma
0107214070 Add example of an oVirt URI to the manpage
https://bugzilla.redhat.com/show_bug.cgi?id=1142769
2014-09-26 09:22:12 -05:00
Jonathon Jongsma
882a59596d Add documentation for fullscreen monitor mapping
see https://bugzilla.redhat.com/show_bug.cgi?id=1142769
2014-09-26 09:22:12 -05:00
Jonathon Jongsma
55172bd8a7 Initialize fullscreen display map to fallback
If uuid was never set, we never checked the 'fallback' monitor map.
Initializing the monitor map to the fallback value at startup solves
this issue. This allows fallback mode to work with older servers that
don't send the UUID.
2014-09-26 09:22:12 -05:00
Jonathon Jongsma
c4d1347a6d Unset app 'fullscreen' when leaving fullscreen
Previously, the fullscreen floating toolbar and the "toggle-fullscreen"
hotkey (which maps to the menu item action) had slightly different
methods of exiting fullscreen. The floating toolbar method unset the
'fullscreen' property on the application (which causes all windows to
simultaneously exit fullscreen), whereas the hotkey did not. This had a
side-effect of preventing the display from auto re-sizing if it was
fullscreened again.  After this change, both the hotkey and the toolbar
button will unset the application-level 'fullscreen' property when
exiting fullscreen mode.

Resolves: rhbz#1022608
2014-09-26 09:20:55 -05:00
Jonathon Jongsma
804564e246 VirtViewerDisplayVnc: set 'session' property
Set the display's session property in the constructor. If the session is
not set, then virt_viewer_display_get_session() doesn't return anything
useful.
2014-09-24 10:21:22 -05:00
Jonathon Jongsma
a15bbac320 Make default window size a bit more useful
Currently, windows have a default size of 400x400 pixels. This is a
strange aspect ratio for a display, and it is also too small to be
useful for much. Since the default window size determines the initial
size of newly-enabled displays, it would be nice if we used a slightly
better size.
2014-09-24 10:21:22 -05:00
Jonathon Jongsma
29c8cadd40 Set initial window size to display desktop size
When setting the 'display' for a VirtViewerWindow, the initial size for
that window should be the size of the remote display. So we synthesize a
desktop resize event when setting a new display for a window.  This is
only done for enabled displays. Disabled displays generally have a size
of 0x0, which would result in the window being at it's minimum size, so
just allow the window to use its default size.
2014-09-24 10:21:22 -05:00
Jonathon Jongsma
f03285ba8d Create windows on demand, not at startup
Previously, a window was created at startup for each display, even if
the display was not enabled. This resulted in a fixed 1:1 association
between windows and remote displays. Since there was always one window
created at startup to display status messages (the "main window"), this
was always associated with remote display #1. But if the first remote
display was not enabled, we ended up with a extra black window with a
message saying ("Waiting for display 1...").

By creating windows on demand, we can re-use the "main window" for any
arbitrary display, even if it's not display #1.

Resolves: rhbz#1032939
2014-09-24 10:21:22 -05:00
Jonathon Jongsma
4537047890 VirtViewerApp: store windows in a list
Use a list to store the application's windows.  This is another step
towards separating the window from the guest display ID.
2014-09-24 10:21:22 -05:00
Jonathon Jongsma
0e6735b4a4 VirtViewerDisplay: add convenience API for getting nth
g_object_get(...) can be cumbersome, so add convenience API for getting
the display ID ("nth-display") property:

    virt_viewer_display_get_nth()
2014-09-24 10:20:12 -05:00
Jonathon Jongsma
573c1cfc91 App: keep hash table of displays
This is part of a re-factoring that will de-couple the client window
from the remote display id.
2014-09-24 10:20:12 -05:00
Jonathon Jongsma
f26a5fe16c Don't show extra screens in fullscreen mode
When using the fullscreen display mapping configuration file, extra
monitors could end up enabled by mistake. This was because
virt_viewer_app_get_initial_monitor_for_display would end up returning
Nmonitor = Ndisplay when the display map hash lookup failed. In
reality, when a display map is specified, but the hash lookup fails,
the display should not be enabled. This function now returns -1 to
distinguish this case, and the display is not enabled when this value is
returned.

Resolves issue described at
https://bugzilla.redhat.com/show_bug.cgi?id=1129477#c9
2014-09-24 10:19:29 -05:00
Jonathon Jongsma
f317e95096 Move monitor mapping into app_window_try_fullscreen()
Rather than requiring all callers to calculate the initial monitor
mapping before calling app_window_try_fullscreen, move the
responsibility for calculating the correct monitor into this function.
This makes it less likely that somebody will forget and a display will
get placed on the wrong monitor.
2014-09-24 09:43:46 -05:00
Christophe Fergeau
5d6b1b8cce Don't unref 'display' in VirtViewerDisplaySpice::finalize
Right after being created, the SpiceDisplay 'display' private member is
added to the VirtViewerDisplaySpice GTK+ container with
gtk_container_add. This call will take ownership of the floating
reference that SpiceDisplay got upon creation.
This means VirtViewerDisplaySpice::display is a pointer to SpiceDisplay,
but it must not be unref'ed when the object is destroyed as we don't own
that reference.
As the container which owns the reference is the
VirtViewerDisplaySpice instance itself, we don't need to take an
additional reference here.

This fixes a crash when exiting remote-viewer after connecting to a
SPICE VM:
  #0  0x00007ffff3f33a81 in g_type_check_instance_is_fundamentally_a (type_instance=0x874500, fundamental_type=80) at gtype.c:3981
  #1  0x00007ffff3f19f96 in g_object_unref (_object=0x874500) at gobject.c:3067
  #2  0x000000000042a1ea in virt_viewer_display_spice_finalize (obj=0x6ebc30) at virt-viewer-display-spice.c:65
  #3  0x00007ffff3f1a257 in g_object_unref (_object=0x6ebc30) at gobject.c:3170
  #4  0x0000000000428de7 in destroy_display (data=0x6ebc30) at virt-viewer-session-spice.c:649
  #5  0x00007ffff3bbb51b in g_ptr_array_foreach (array=0x7e12a0, func=0x428d71 <destroy_display>, user_data=0x0) at garray.c:1502
  #6  0x00007ffff3bbaadf in ptr_array_free (array=0x7e12a0, flags=FREE_SEGMENT) at garray.c:1088
  #7  0x00007ffff3bbaa10 in g_ptr_array_unref (array=0x7e12a0) at garray.c:1036
  #8  0x00007ffff3bcf9bd in g_data_set_internal (datalist=0xa0adb0, key_id=1622, new_data=0x0, new_destroy_func=0x0, dataset=0x0) at gdataset.c:407
  #9  0x00007ffff3bcfe74 in g_datalist_id_set_data_full (datalist=0xa0adb0, key_id=1622, data=0x0, destroy_func=0x0) at gdataset.c:670
  #10 0x00007ffff3f1a771 in g_object_set_data (object=0xa0ada0, key=0x437252 "virt-viewer-displays", data=0x0) at gobject.c:3461
  #11 0x0000000000429b56 in virt_viewer_session_spice_channel_destroy (s=0x6eb910, channel=0xa0ada0, session=0x8cb3a0) at virt-viewer-session-spice.c:854
  #12 0x00007ffff3f12d81 in g_cclosure_marshal_VOID__OBJECT (closure=0x8e8fd0, return_value=0x0, n_param_values=2, param_values=0x7fffffffcd80, invocation_hint=0x7fffffffccc0, marshal_data=0x0) at gmarshal.c:1272
  #13 0x00007ffff3f0e143 in g_closure_invoke (closure=0x8e8fd0, return_value=0x0, n_param_values=2, param_values=0x7fffffffcd80, invocation_hint=0x7fffffffccc0) at gclosure.c:768
  #14 0x00007ffff3f2aef0 in signal_emit_unlocked_R (node=0x7c1f20, detail=0, instance=0x6eb910, emission_return=0x0, instance_and_params=0x7fffffffcd80) at gsignal.c:3553
  #15 0x00007ffff3f2a1f3 in g_signal_emit_valist (instance=0x6eb910, signal_id=219, detail=0, var_args=0x7fffffffd058) at gsignal.c:3309
  #16 0x00007ffff3f2a746 in g_signal_emit (instance=0x6eb910, signal_id=219, detail=0) at gsignal.c:3365
  #17 0x00007ffff529d784 in spice_session_channel_destroy (session=0x6eb910, channel=0xa0ada0) at spice-session.c:1990
  #18 0x00007ffff529ed25 in spice_channel_dispose (gobject=0xa0ada0) at spice-channel.c:153
  #19 0x00007ffff52acd26 in spice_display_channel_dispose (object=0xa0ada0) at channel-display.c:136
  #20 0x00007ffff3f1a132 in g_object_unref (_object=0xa0ada0) at gobject.c:3133
  #21 0x00007ffff52a4afb in spice_channel_delayed_unref (data=0xa0ada0) at spice-channel.c:2156
  #22 0x00007ffff3bf21d1 in g_idle_dispatch (source=0xa35a00, callback=0x7ffff52a49f3 <spice_channel_delayed_unref>, user_data=0xa0ada0) at gmain.c:5320
  #23 0x00007ffff3bef8eb in g_main_dispatch (context=0x68a920) at gmain.c:3064
  #24 0x00007ffff3bf0661 in g_main_context_dispatch (context=0x68a920) at gmain.c:3663
  #25 0x00007ffff3bf0853 in g_main_context_iterate (context=0x68a920, block=1, dispatch=1, self=0x6c8c60) at gmain.c:3734
  #26 0x00007ffff3bf0c7c in g_main_loop_run (loop=0x889b20) at gmain.c:3928
  #27 0x00007ffff69be44f in gtk_main () at gtkmain.c:1207
  #28 0x0000000000431896 in main (argc=1, argv=0x7fffffffd648) at remote-viewer-main.c:183
2014-09-23 15:19:47 +02:00
Fabiano Fidêncio
a5ce2ed3ae Do not fail when the auth dialog is cancelled
https://bugzilla.redhat.com/show_bug.cgi?id=1145460
2014-09-23 15:06:27 +02:00
Fabiano Fidêncio
e86e885380 Revert changes related to numpad accelerators
Due to a GTK+ limitation and bad testing from my side, I've pushed
two patches trying to add support to use Ctrl + {+, -, 0} from numpad
to control zoom-in, zoom-out and zoom-reset.
Unfortunately, with the first patch (3a168815) I've duplicated the menu
items related to the zoom functions. With the second one (55cdb986),
provided to not show the duplicated menu items, we came back to the
initial state, where the numpad accelerators don't work.

So, in resume, multiple accelerators in a GTK+ widget are only supported
on applications using GApplication, what is not our case and won't be
till we drop the GTK+2 support.

Revert "Do not show duplicated menu items" and
Revert "Add support to use numpad accelarators for zoom-{in.out,reset}"

This reverts commits 55cdb9867d and
3a168815b7.
2014-09-23 15:00:19 +02:00
Christophe Fergeau
56cda33ff8 Remove inaccurate G_GNUC_UNUSED
The 'user_data' variable is used in the callback.
2014-09-22 14:18:12 +02:00
Fabiano Fidêncio
276ca0f753 Add support to view the password entry content
Allow users to check if the entered password is right and/org modify
the password easily in case it's wrong.
2014-09-17 13:45:46 +02:00
Fabiano Fidêncio
e825e183a1 Mark all strings for translation in the auth dialog
A few strings weren't marked for translation in the authentication
dialog.
2014-09-15 14:54:02 +02:00
Fabiano Fidêncio
55cdb9867d Do not show duplicated menu items
When the support to use numpad accelerators for zoom-{in,out,reset}
was added (3a168815), by mistake, we have added duplicated buttons
in View -> Zoom.
2014-09-15 14:53:53 +02:00
Christophe Fergeau
69eccb59f9 Fix --without-spice-gtk --with-ovirt build
The oVirt foreign menu support reused some existing bits from the older
SPICE controller foreign menu code. However, this controller code is
only built when spice-gtk support is built, while the oVirt foreign menu
code could be used with VNC as well. Trying to build the ovirt foreign
menu code without spice-gtk causes build issues due to missing
functions, or missing declarations, ...

The libgovirt/spice-gtk code which is entangled is the code to update
the foreign menu when its content changes, or when a new window is
opened. Making the oVirt-specific code independant from the
spice-gtk-specific code is not too complicated, but this comes at the
expense of a bit of code duplication, but this is only simple code
iterating over the GHashTable storing the opened windows.

Resolves: rhbz#1127156
2014-09-12 17:08:42 +02:00
Christophe Fergeau
fe7927733c Add translatable file to POTFILES.in 2014-09-12 17:08:42 +02:00
Jonathon Jongsma
8f16b38f9e Remove extra ref on SpiceDisplay
There's no need to ref the SpiceDisplay widget when adding it to a
container. The container will take its own ref.
2014-09-11 09:30:23 -05:00
Jonathon Jongsma
401906afd7 VirtViewer: Fix memory leaks
Don't leak priv->uri or priv->domkey from VirtViewer class
2014-09-11 09:30:17 -05:00