Do not fail when the auth dialog is cancelled

https://bugzilla.redhat.com/show_bug.cgi?id=1145460
This commit is contained in:
Fabiano Fidêncio 2014-09-22 17:14:39 +02:00
parent e86e885380
commit a5ce2ed3ae

View File

@ -57,6 +57,7 @@ struct _VirtViewerPrivate {
gboolean withEvents; gboolean withEvents;
gboolean waitvm; gboolean waitvm;
gboolean reconnect; gboolean reconnect;
gboolean auth_cancelled;
}; };
G_DEFINE_TYPE (VirtViewer, virt_viewer, VIRT_VIEWER_TYPE_APP) G_DEFINE_TYPE (VirtViewer, virt_viewer, VIRT_VIEWER_TYPE_APP)
@ -615,6 +616,7 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
{ {
char **username = NULL, **password = NULL; char **username = NULL, **password = NULL;
VirtViewer *app = cbdata; VirtViewer *app = cbdata;
VirtViewerPrivate *priv = app->priv;
int i; int i;
int ret = -1; int ret = -1;
@ -638,11 +640,11 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
if (username || password) { if (username || password) {
VirtViewerWindow *vwin = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(app)); VirtViewerWindow *vwin = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(app));
GtkWindow *win = virt_viewer_window_get_window(vwin); GtkWindow *win = virt_viewer_window_get_window(vwin);
ret = virt_viewer_auth_collect_credentials(win, priv->auth_cancelled = !virt_viewer_auth_collect_credentials(win,
"libvirt", "libvirt",
app->priv->uri, app->priv->uri,
username, password); username, password);
if (ret < 0) if (priv->auth_cancelled)
goto cleanup; goto cleanup;
} else { } else {
ret = 0; ret = 0;
@ -695,8 +697,11 @@ virt_viewer_connect(VirtViewerApp *app)
&auth_libvirt, &auth_libvirt,
oflags); oflags);
if (!priv->conn) { if (!priv->conn) {
virt_viewer_app_simple_message_dialog(app, _("Unable to connect to libvirt with URI %s"), if (!priv->auth_cancelled) {
priv->uri ? priv->uri : _("[none]")); virt_viewer_app_simple_message_dialog(app, _("Unable to connect to libvirt with URI %s"),
priv->uri ? priv->uri : _("[none]"));
}
return -1; return -1;
} }