ovirt: Allow to cancel authentication without showing error dialog

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1201604
This commit is contained in:
Pavel Grunt 2015-03-16 11:20:02 +01:00
parent 0c8f07ea64
commit 0443bd113f
2 changed files with 24 additions and 1 deletions

View File

@ -203,7 +203,18 @@ AS_IF([test "x$with_ovirt" != "xno"],
[have_ovirt=no])
AS_IF([test "x$have_ovirt" = "xyes"],
[AC_DEFINE([HAVE_OVIRT], 1, [Have libgovirt?])],
[AC_DEFINE([HAVE_OVIRT], 1, [Have libgovirt?])]
[SAVED_CFLAGS="$CFLAGS"
SAVED_LIBS="$LIBS"
CFLAGS="$OVIRT_CFLAGS"
LIBS="$OVIRT_LIBS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <govirt/govirt.h>]],
[static int err = OVIRT_REST_CALL_ERROR_CANCELLED;
void *fun = rest_proxy_auth_cancel;])],
[AC_DEFINE([HAVE_OVIRT_CANCEL], 1, [Have rest_proxy_auth_cancel and OVIRT_REST_CALL_ERROR_CANCELLED?])],
[])
CFLAGS="$SAVED_CFLAGS"
LIBS="$SAVED_LIBS"],
[AS_IF([test "x$with_ovirt" = "xyes"],
[AC_MSG_ERROR([oVirt support requested but libgovirt not found])
])

View File

@ -729,6 +729,10 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth,
"username", username,
"password", password,
NULL);
#ifdef HAVE_OVIRT_CANCEL
} else {
rest_proxy_auth_cancel(auth);
#endif
}
g_free(username);
@ -863,6 +867,14 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
api = ovirt_proxy_fetch_api(proxy, &error);
if (error != NULL) {
g_debug("failed to get oVirt 'api' collection: %s", error->message);
#ifdef HAVE_OVIRT_CANCEL
if (g_error_matches(error, OVIRT_REST_CALL_ERROR, OVIRT_REST_CALL_ERROR_CANCELLED)) {
g_clear_error(&error);
g_set_error_literal(&error,
VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED,
_("Authentication was cancelled"));
}
#endif
goto error;
}
vms = ovirt_api_get_vms(api);