Hey, I did not test it but I'd say this looks good. Christophe On Wed, Oct 01, 2014 at 04:41:30PM +0200, Fabiano Fidêncio wrote: > Lets prefill the username entry using the user name of the > current user. > --- > src/remote-viewer.c | 3 +++ > src/virt-viewer-session-spice.c | 16 ++++++++++------ > src/virt-viewer-session-vnc.c | 10 +++++++--- > src/virt-viewer.c | 4 ++++ > 4 files changed, 24 insertions(+), 9 deletions(-) > > diff --git a/src/remote-viewer.c b/src/remote-viewer.c > index 49981aa..164067d 100644 > --- a/src/remote-viewer.c > +++ b/src/remote-viewer.c > @@ -705,6 +705,9 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth, > "username", &username, > NULL); > > + if (username == NULL || *username == '\0') > + username = g_strdup(g_get_user_name()); > + > window = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(user_data)); > success = virt_viewer_auth_collect_credentials(virt_viewer_window_get_window(window), > "oVirt", > diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c > index 399e9a6..2a8e490 100644 > --- a/src/virt-viewer-session-spice.c > +++ b/src/virt-viewer-session-spice.c > @@ -536,13 +536,17 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED > > self->priv->pass_try++; > > - /* A username is *only* pre-filled in case where some authentication > - * error happened. Unfortunately, we don't have a clear way to > - * differantiate bewteen invalid username and invalid password. > - * So, in both cases the username entry will be pre-filled with the > - * username used in the previous attempt. */ > - if (username_required) > + /* The username is firstly pre-filled with the username of the current > + * user and in case where some authentication error happened, the > + * username entry will be prefilled with the last username used. > + * Unfortunately, we don't have a clear way to differantiate bewteen > + * invalid username and invalid password. So, in both cases the username > + * entry will be pre-filled with the username used in the previous attempt. */ > + if (username_required) { > g_object_get(self->priv->session, "username", &user, NULL); > + if (user == NULL || *user == '\0') > + user = g_strdup(g_get_user_name()); > + } > > ret = virt_viewer_auth_collect_credentials(self->priv->main_window, > "SPICE", > diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c > index 29bd111..5a2dd86 100644 > --- a/src/virt-viewer-session-vnc.c > +++ b/src/virt-viewer-session-vnc.c > @@ -283,9 +283,13 @@ virt_viewer_session_vnc_auth_credential(GtkWidget *src G_GNUC_UNUSED, > > VirtViewerFile *file = virt_viewer_session_get_file(VIRT_VIEWER_SESSION(self)); > if (file != NULL) { > - if (wantUsername && virt_viewer_file_is_set(file, "username")) { > - username = virt_viewer_file_get_username(file); > - wantUsername = FALSE; > + if (wantUsername) { > + if (virt_viewer_file_is_set(file, "username")) { > + username = virt_viewer_file_get_username(file); > + wantUsername = FALSE; > + } else { > + username = g_strdup(g_get_user_name()); > + } > } > if (wantPassword && virt_viewer_file_is_set(file, "password")) { > password = virt_viewer_file_get_password(file); > diff --git a/src/virt-viewer.c b/src/virt-viewer.c > index c6066c5..1b0ef65 100644 > --- a/src/virt-viewer.c > +++ b/src/virt-viewer.c > @@ -640,6 +640,10 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred, > if (username || password) { > VirtViewerWindow *vwin = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(app)); > GtkWindow *win = virt_viewer_window_get_window(vwin); > + > + if (*username == NULL || **username == '\0') > + *username = g_strdup(g_get_user_name()); > + > priv->auth_cancelled = !virt_viewer_auth_collect_credentials(win, > "libvirt", > app->priv->uri, > -- > 1.9.3 > > _______________________________________________ > virt-tools-list mailing list > virt-tools-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/virt-tools-list
Attachment:
pgpLJMRHohhFC.pgp
Description: PGP signature
_______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list