From 2561c171e74747f47593192c5e9fd663fc3d0d8f Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Tue, 12 Aug 2014 11:03:27 -0500 Subject: [PATCH] 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. --- src/remote-viewer.c | 7 ++++--- src/virt-viewer-auth.c | 4 ++-- src/virt-viewer-auth.h | 10 +++++----- src/virt-viewer-session-vnc.c | 10 +++++----- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/remote-viewer.c b/src/remote-viewer.c index 89ad227..5f5fa3d 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -734,17 +734,18 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth, gchar *username = NULL; gchar *password = NULL; VirtViewerWindow *window; + gboolean success = FALSE; g_object_get(proxy, "username", &username, NULL); window = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(user_data)); - int ret = virt_viewer_auth_collect_credentials(virt_viewer_window_get_window(window), + success = virt_viewer_auth_collect_credentials(virt_viewer_window_get_window(window), "oVirt", NULL, &username, &password); - if (ret == 0) { + if (success) { g_object_set(G_OBJECT(proxy), "username", username, "password", password, @@ -753,7 +754,7 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth, g_free(username); g_free(password); - return (ret == 0); + return success; } diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c index a796619..556a10b 100644 --- a/src/virt-viewer-auth.c +++ b/src/virt-viewer-auth.c @@ -36,7 +36,7 @@ * field will be pre-filled with this value. The existing string will be freed * before setting the output parameter to the user-entered value. */ -int +gboolean virt_viewer_auth_collect_credentials(GtkWindow *window, const char *type, const char *address, @@ -102,7 +102,7 @@ virt_viewer_auth_collect_credentials(GtkWindow *window, gtk_widget_destroy(GTK_WIDGET(dialog)); g_object_unref(G_OBJECT(creds)); - return response == GTK_RESPONSE_OK ? 0 : -1; + return response == GTK_RESPONSE_OK; } /* diff --git a/src/virt-viewer-auth.h b/src/virt-viewer-auth.h index ad932c5..85e3bbc 100644 --- a/src/virt-viewer-auth.h +++ b/src/virt-viewer-auth.h @@ -32,11 +32,11 @@ #include "virt-viewer-session.h" #include "virt-viewer-util.h" -int virt_viewer_auth_collect_credentials(GtkWindow *window, - const char *type, - const char *address, - char **username, - char **password); +gboolean virt_viewer_auth_collect_credentials(GtkWindow *window, + const char *type, + const char *address, + char **username, + char **password); #endif /* diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c index e2f90f2..8de39d4 100644 --- a/src/virt-viewer-session-vnc.c +++ b/src/virt-viewer-session-vnc.c @@ -294,12 +294,12 @@ virt_viewer_session_vnc_auth_credential(GtkWidget *src G_GNUC_UNUSED, } if (wantUsername || wantPassword) { - int ret = virt_viewer_auth_collect_credentials(self->priv->main_window, - "VNC", NULL, - wantUsername ? &username : NULL, - wantPassword ? &password : NULL); + gboolean ret = virt_viewer_auth_collect_credentials(self->priv->main_window, + "VNC", NULL, + wantUsername ? &username : NULL, + wantPassword ? &password : NULL); - if (ret < 0) { + if (!ret) { vnc_display_close(self->priv->vnc); goto cleanup; }