Commit Graph

80 Commits

Author SHA1 Message Date
Lukas Venhoda
f4018a8dbe remote-viewer: Connect dialog moved to its own file
Connect dialog from remote-viewer is now in its own file.
Most other dialog also have their own files.
This will make changing the dialog into a window easier.

Renamed connect_dialog to remote_viewer_connect_dialog.
2015-06-16 14:10:03 +02:00
Pavel Grunt
0443bd113f ovirt: Allow to cancel authentication without showing error dialog
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1201604
2015-04-14 15:03:48 +02:00
Fabiano Fidêncio
f580f1ea54 remote-viewer: Avoid simple_message_dialog() when errors can be propagated
Remove the dialog used to report errors when create_session() fails,
propagating the error is enough and it is already done.

Related: rhbz#1085216
2015-03-27 16:49:53 +01:00
Fabiano Fidêncio
f1204f0e69 virt-viewer-app: create_session() should return a boolean
By convention functions that take GError parameters should return FALSE
(or NULL) or error.

Related: rhbz#1085216
2015-03-27 16:35:35 +01:00
Fabiano Fidêncio
f9c4a03bd7 virt-viewer-app: Add a GError arg to create_session()
This is part of a small re-factoring that will have all connection
errors, when we won't be able to connect regardless of what changes on
the remote host, being treated by virt_viewer_app_initial_connect(),
avoiding weird behaviors as we have nowadays (like more than one error
dialog being shown or having the virt-viewer waiting forever for a guest
that will never show up).

Related: rhbz#1085216
2015-03-27 16:12:58 +01:00
Pavel Grunt
1a619f2383 Report errors in one place
Since the error is propagated to the main, report the error there.
To make it work GError VIRT_VIEWER_ERROR_FAILED is set for all
failing states and it is reported using virt_viewer_app_simple_message_dialog().
2015-03-23 19:32:02 +01:00
Pavel Grunt
1bcd8d0fe6 Exit normally when canceling dialog
This applies for:
 libvirt authentication dialog (e.g. virt-viewer --attach guest)
 'recent connection' dialog (e.g. remote-viewer)
 'vm choose' dialog when connecting without specifying the vm name

This is done by using a new GError VIRT_VIEWER_ERROR_CANCELLED.
2015-03-23 19:32:02 +01:00
Christophe Fergeau
1eafd0407e ovirt: Don't try to use invalid port numbers
If a remote oVirt VM don't specify a port/secure port number, we'd still
try to pass it down to spice-gtk, which would then complain that 0 (the
default value) isn't a valid port number.
This commit make sure we filter out the default port/secure-port value
and pass NULL to spice-gtk instead when we get these values.
2015-03-13 15:51:58 +01:00
Christophe Fergeau
32d0ae09b8 foreign-menu: Don't show empty foreign menu on secondary displays
When using ovirt://, the foreign menu will only be shown in the primary
window after getting notified about OvirtForeignMenu::files (ie when
it managed to fetch some ISO files to show in the foreign menu).

However, for secondary windows, the foreign menu will be added to the
window even if there are no files to show. This commit makes sure we
destroy the window foreign menu whenever it would be empty.
2015-03-13 15:51:58 +01:00
Christophe Fergeau
ccafa32fe0 ovirt: Fail gracefully when hostname is missing
When parsing info returned by oVirt REST API, the hostname should be
present. However, I recently run remote-viewer against a buggy oVirt
instance where the hostname was missing. This commit handles better this
situation by displaying an error message and exiting.
2015-03-12 17:48:36 +01:00
Christophe Fergeau
f9577b9197 ovirt: Take into account SPICE proxy
VMs managed by oVirt can be hidden behind a proxy. This commit allows
remote-viewer to make use of this information when it's available
A recent oVirt instance is needed so that it's available through the
REST API, as well as libgovirt 0.3.3 or newer.
With older oVirt/libgovirt versions, the worst that can happen is a
runtime warning in the console, and an impossibility to connect to VMs
behind a proxy, so this commit is not raising the minimum libgovirt
requirement.
2015-03-12 17:48:22 +01:00
Pavel Grunt
45c6fc9b06 Do not add "https://" and "/api" to oVirt URI
It is deprecated since govirt 0.3.1 (and virt-viewer already depends on
govirt 0.3.2).

Silences:
(remote-viewer:19420): libgovirt-WARNING **: Passing a full http:// or https:// URI to ovirt_proxy_new() is deprecated
(remote-viewer:19420): libgovirt-WARNING **: Passing an URI ending in /api to ovirt_proxy_new() is deprecated
2015-02-18 14:07:50 +01:00
Pavel Grunt
c3d24f8bb6 Set a transient parent for GtkDialogs
Silence the Gtk 3.14 message:
"GtkDialog mapped without a transient parent. This is discouraged."
2014-12-19 17:39:53 +01:00
Marc-André Lureau
15c7d17b96 Remove VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED
This error type isn't really an error, it is used to skip error report
code. The functions can simply return FALSE on failure, without GError
set, to indicate that program should quit normally.
2014-11-25 13:00:49 +01:00
Daniel P. Berrange
041a39f97f Avoid use of non-literal string with g_debug 2014-10-27 16:43:13 +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
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
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
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
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
Jonathon Jongsma
2561c171e7 Change collect_credentials() to return a boolean
Instead of returning 0 for success and -1 for failure, change to a
boolean success value to be more consistent with the rest of the
virt-viewer code.
2014-08-26 16:54:01 -05:00
Jonathon Jongsma
b7c8049460 Auth: fix leak of username
When collect_credentials() returns a failure status, 'username' was
potentially leaked.
2014-08-26 16:54:01 -05:00
Jonathon Jongsma
ad8966ccf9 remote-viewer: oVirt username review fixes
Minor fixes from patch review

rhbz#1061826
2014-08-19 14:15:53 -05:00
Christophe Fergeau
6ab5444c81 Create foreign menu from .vv file information
When the .vv file has an [ovirt] section, we should try to create a foreign
menu out of it. This will allow remote-viewer to offer a menu to change the
currenty inserted cdrom.

Contrary to the ovirt:// case when we already have fetched an OvirtAPI
and OvirtVm instance in order to get the SPICE/VNC connection details,
when working from a .vv file, we'll need to get them from the REST API.
Authentication should happen through the JSESSIONID cookie, if that
fails we want to give up on using the foreign menu, so we don't need to
set up authentication callbacks.
2014-08-18 13:20:42 +02:00
Christophe Fergeau
3df1e5a17a ovirt: Use OvirtForeignMenu class
After the previous commit which introduced the OvirtForeignMenu
class, we can now make use of it in the remote-viewer UI code.
2014-08-18 13:20:42 +02:00
Christophe Fergeau
914f75ee8d ovirt: Remove extra '/' from oVirt URI
The 'path' part of the URI will always start with a '/' when present as
this is what separates it from the hostname. When rebuilding the final
URI, the current code inserts a '/' by itself between the hostname and
the path, which results in URIs with an extra '/':
https://ovirt.example.com//some/path/api

This is not only cosmetic as this can cause issues with cookie handling
if libgovirt accesses //some/path/api while the cookie is set for
/some/path/api.
2014-08-18 13:20:42 +02:00
Jonathon Jongsma
49abd71dae remote-viewer: allow username in ovirt URIs
When the user launches remote-viewer with an ovirt URI of the form

        ovirt://user@host/vmname

Pre-populate the authentication dialog with the specified username. We
don't support specifying the password on the commandline, since that is
a potential security risk.

rhbz#1061826
2014-08-18 13:20:42 +02:00
Christophe Fergeau
5dcd46c0b1 Remove unused RemoteViewerPrivate members 2014-08-04 17:41:50 +02:00
Christophe Fergeau
4eaeab65a3 Remove incorrect G_GNUC_UNUSED from remote_viewer_window_added
The 'app' parameter is used in the function.
2014-08-04 17:41:50 +02:00
Marc-André Lureau
ed939ad00d Replace DEBUG_LOG with g_debug
https://bugzilla.redhat.com/show_bug.cgi?id=1107518
2014-06-10 18:13:37 +02:00
Jonathon Jongsma
e23f6fa4c4 Set freed variables to NULL in remote_viewer_start()
Coverity warns that 'type' can sometimes be used or free after already having
been freed.  This can happen when open_recent_dialog is true and we jump back up
to the retry_dialog label.  To prevent this, make sure the freed variables are
set to NULL after freeing.
2014-06-03 11:13:14 -05:00
Jonathon Jongsma
3e9d9266d9 Improve remote-viewer connection dialog
Based on the new design for the 'connect to server' dialog from Nautilus.
2014-06-03 11:11:09 -05:00
Marc-André Lureau
7212c8745a spice: do not open in fullscreen with CONTROLLER_AUTO_DISPLAY_RES
This flag is always set when using the rhevm user portal. Best is
probably to ignore it, now that fullscreen has simplified unique
behaviour.
2014-02-26 12:42:20 +01:00
Jonathon Jongsma
0383cc4c9b Improve window title when connected to newer spice-server
Recent spice servers send the guest vm name and uuid to the client.  We can use
these values to display the proper vm name in the window title if a title is not
specified on the commandline. We can also be smarter about the title in
virt-viewer as well.

If a title is specified on the comamndline (-t/--title=foo), we use that.  If not,
we fall back to the vm name.  If that is empty, we fall back to the uri of the
connection.

Comparison between old behavior and new behavior

Using new spice-server
Command                                     Old title                   New title
-------                                     ---------                   ---------
remote-viewer -t xyz spice://host:port      xyz                         xyz
remote-viewer spice://host:port             spice://host:port           <vmname>
virt-viewer <vmname>                        <vmname>                    <vmname>
virt-viewer <uuid>                          <uuid>                      <vmname>

Using old spice-server
Command                                     Old title                   New title
-------                                     ---------                   ---------
remote-viewer -t xyz spice://host:port      xyz                         xyz
remote-viewer spice://host:port             spice://host:port           spice://host:port
virt-viewer <vmname>                        <vmname>                    <vmname>
virt-viewer <uuid>                          <uuid>                      <vmname>
2014-02-11 11:56:43 -06:00
Christophe Fergeau
06b2c38246 Reshow connection dialog on errors
remote-viewer behaviour is currently inconsistent in the connection dialog:
if the user enters a valid URI, but then remote-viewer fails to connect
to it, then we'll show again the connection dialog through a call
to virt_viewer_app_start() in remote_viewer_deactivated(). If instead we
enter an invalid URI in the connection dialog, then remote-viewer will
report an error and quit.

This commit makes sure in the latter case, we report the error and show
again the connection dialog. The user can press 'Cancel' in the
connection dialog to get out of remote-viewer as in this case, we
return directly FALSE rather than going through the cleanup: label
and looping.
2013-11-13 11:29:05 +01:00
Christophe Fergeau
30bb4019fd Handle virt_viewer_app_start() errors
remote_viewer_deactivated() can be calling virt_viewer_app_start()
without checking whether it returns TRUE or FALSE. It returns FALSE
when it was not successful (when it failed to parse the URI to connect
to for example, or whe the user presses Cancel in the connection dialog).

This means that if the user starts remote-viewer, enters a valid URI
in the connection dialog to which it cannot connect to
(spice://example.com:999) and then presses Cancel in the connection
dialog that appears after the connection  failure, then remote-viewer
will be sitting there with an empty window doing nothing.

This commit ensures we chain to the parent class when
virt_viewer_app_start() returns FALSE, which causes remote-viewer to
exit.
2013-11-13 11:29:05 +01:00
Christophe Fergeau
b19a246c5c Fix window title after failed connection
When using the connection dialog, if the user picks an invalid
URI first causing a failed connection, and then picks/enters a valid
URI, remote-viewer window title will be set to the first invalid URI,
not to the second one which was entered.

As the user may have specified a window title to use on the command
line (-t option), we need to be careful not to override that when
setting the window title on the second attempt.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1024309
2013-11-13 11:29:05 +01:00
Jonathon Jongsma
bd914bdea2 Drop basic fullscreen mode
Remove the distinction between --full-screen and --full-screen=auto-conf.  Just
make --full-screen behave like auto-conf did.  There's really no advantage to
having two slightly different fullscreen startup modes.
2013-11-13 11:10:06 +01:00
Christophe Fergeau
73a4e9993d ovirt: Only set SPICE CA cert if it's non NULL
We currently reuse the oVirt CA cert for SPICE connection as well,
but it may not be set. When this happens, we don't want to try to use
it.
2013-10-30 10:52:53 +01:00
Christophe Fergeau
daa499f27e ovirt: Don't automatically download CA certificate
The CA certificate to use to authenticate the various hosts in
an oVirt instance can be fetched from https://ovirt.example.com/ca.crt.
However, the gio API we are using does not seem to be checking the
server-side certificate of ovirt.example.com before connecting to it,
which could lead to man-in-the-middle attacks. Now that the CA
certificate to use can be specified from the command line using
--ovirt-ca-file, we can remove this automatic fetching of the CA
certificate.
2013-10-30 10:52:53 +01:00
Christophe Fergeau
9eb3747f1f ovirt: Honour oVirt command line options
libgovirt 0.3.0 and newer can be passed from the commandline a CA
certificate to use during SSL communications. This commit adds support
for this option to remote-viewer.
2013-10-30 10:52:53 +01:00
Christophe Fergeau
8df64ae4ec ovirt: Remove use of deprecated APIs
ovirt_proxy_fetch_vms/ovirt_proxy_lookup_vm have been deprecated
in govirt 0.3.0
2013-10-30 10:52:53 +01:00
Christophe Fergeau
69ffdb50b9 Clean-up spaces before/after URI in connection dialog
When starting remote-viewer with no argument, a connection dialog
is shown. If the URI the user types in this dialog as trailing
or leading spaces, then connection will fail because remote-viewer
will keep them as if they were significant.
This commit makes sure we remove spaces at the beginning/end of
the URI before trying to use it.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1024199
2013-10-29 15:12:17 +01:00
Marc-André Lureau
980de2d331 Try to share more GOption code between r-v and v-v 2013-08-20 13:39:46 +02:00
Marc-André Lureau
9cad9ae00c Fix build --without-spice-gtk 2013-06-28 16:47:27 +02:00
Christophe Fergeau
7c0967fc8c ovirt: Set host subject if needed
For some VMs, setting host subject on SpiceSession is needed to
be able to connect to it using SPICE/SSL. Until recently, this
was not exposed in oVirt REST API/libgovirt. Since
oVirt 3.2/libgovirt 0.1.0, the host subject is available, this
patch makes use of it.
This should fix connection to oVirt VMs that were migrated to a
different host than the one they were started on.
2013-06-11 15:54:37 +02:00
Marc-André Lureau
df30f9730d Support Spice controller "auto-display-res" flag
The controller "auto-display-res" flag should be use to reconfigure
guest to match client configuration. This is what the
--fullscreen=auto-conf option is already made for.

https://bugzilla.redhat.com/show_bug.cgi?id=967154
2013-05-27 15:29:45 +02:00
Marc-André Lureau
240baeeb44 Show connect dialog again if connection from dialog failed
https://bugzilla.redhat.com/show_bug.cgi?id=864026
2013-05-17 14:15:06 +02:00
Marc-André Lureau
79255e80d5 Move connect dialog to remote-viewer.c 2013-05-17 14:15:06 +02:00
Marc-André Lureau
fdb2e4714a spice: forward secure-channels
This needs spice-gtk >= 0.19.7 and will warn with lower version
2013-04-15 16:46:47 +02:00