[virt-tools-list] [PATCH virt-viewer 1/4] ovirt: Allow to cancel authentication without showing error dialog
Pavel Grunt
pgrunt at redhat.com
Tue Mar 17 09:08:21 UTC 2015
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1201604
---
src/remote-viewer.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 4541515..aa838e3 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -703,6 +703,11 @@ parse_ovirt_uri(const gchar *uri_str, char **rest_uri, char **name, char **usern
return TRUE;
}
+typedef struct {
+ VirtViewerApp *app;
+ gboolean dialog_cancelled;
+} AuthenticateInfo;
+
static gboolean
authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth,
G_GNUC_UNUSED gboolean retrying, gpointer user_data)
@@ -711,6 +716,7 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth,
gchar *password = NULL;
VirtViewerWindow *window;
gboolean success = FALSE;
+ AuthenticateInfo *authenticate_info = user_data;
g_object_get(proxy,
"username", &username,
@@ -719,11 +725,12 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth,
if (username == NULL || *username == '\0')
username = g_strdup(g_get_user_name());
- window = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(user_data));
+ window = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(authenticate_info->app));
success = virt_viewer_auth_collect_credentials(virt_viewer_window_get_window(window),
"oVirt",
NULL,
&username, &password);
+ authenticate_info->dialog_cancelled = !success;
if (success) {
g_object_set(G_OBJECT(proxy),
"username", username,
@@ -843,6 +850,10 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
gchar *ticket = NULL;
gchar *host_subject = NULL;
gchar *guid = NULL;
+ AuthenticateInfo authenticate_info = {
+ .app = app,
+ .dialog_cancelled = FALSE,
+ };
g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
@@ -858,9 +869,13 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
NULL);
ovirt_set_proxy_options(proxy);
g_signal_connect(G_OBJECT(proxy), "authenticate",
- G_CALLBACK(authenticate_cb), app);
+ G_CALLBACK(authenticate_cb), &authenticate_info);
api = ovirt_proxy_fetch_api(proxy, &error);
+ if (authenticate_info.dialog_cancelled) {
+ g_clear_error(&error);
+ goto error;
+ }
if (error != NULL) {
g_debug("failed to get oVirt 'api' collection: %s", error->message);
goto error;
--
2.3.2
More information about the virt-tools-list
mailing list