summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Grunt <pgrunt@redhat.com>2015-03-16 11:20:02 +0100
committerPavel Grunt <pgrunt@redhat.com>2015-04-14 15:03:48 +0200
commit0443bd113f8474ca707c7847e2806a6e374e8a21 (patch)
tree7b4980ccf851c5a16730c74d3f50aa8c3f22969b
parent0c8f07ea64f462f66d21ab473b7f58b8a5c07e0d (diff)
ovirt: Allow to cancel authentication without showing error dialog
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1201604
-rw-r--r--configure.ac13
-rw-r--r--src/remote-viewer.c12
2 files changed, 24 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 45b894d..c99378b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
])
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index b172056..937d06d 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -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);