mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 23:00:54 +00:00
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.
This commit is contained in:
parent
b7c8049460
commit
2561c171e7
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -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
|
||||
/*
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user