diff options
author | Giovanni Panozzo <giovanni@panozzo.it> | 2019-11-01 01:25:10 +0300 |
---|---|---|
committer | Giovanni Panozzo <giovanni@panozzo.it> | 2019-11-01 16:29:13 +0300 |
commit | ad9fc53bb7294e1cf7800c57bc5da85231245b71 (patch) | |
tree | 530239c335f71af930097623c5d08ae8920b2fb3 /src | |
parent | dd54de514e08fbe078b391ac01c1c04c24933afe (diff) |
Better messagepanel plugin API
Diffstat (limited to 'src')
-rw-r--r-- | src/include/remmina/plugin.h | 4 | ||||
-rw-r--r-- | src/include/remmina/types.h | 7 | ||||
-rw-r--r-- | src/remmina_message_panel.h | 5 | ||||
-rw-r--r-- | src/remmina_plugin_manager.c | 3 | ||||
-rw-r--r-- | src/remmina_protocol_widget.c | 134 | ||||
-rw-r--r-- | src/remmina_protocol_widget.h | 3 | ||||
-rw-r--r-- | src/remmina_ssh.c | 90 |
7 files changed, 146 insertions, 100 deletions
diff --git a/src/include/remmina/plugin.h b/src/include/remmina/plugin.h index d08abd770..f5a14cbe1 100644 --- a/src/include/remmina/plugin.h +++ b/src/include/remmina/plugin.h @@ -170,8 +170,8 @@ typedef struct _RemminaPluginService { void (* protocol_plugin_update_align)(RemminaProtocolWidget *gp); void (* protocol_plugin_unlock_dynres)(RemminaProtocolWidget *gp); void (* protocol_plugin_desktop_resize)(RemminaProtocolWidget *gp); - gint (* protocol_plugin_init_authpwd)(RemminaProtocolWidget *gp, RemminaAuthpwdType authpwd_type, gboolean allow_password_saving); - gint (* protocol_plugin_init_authuserpwd)(RemminaProtocolWidget *gp, gboolean want_domain, gboolean allow_password_saving); + gint (* protocol_plugin_init_auth)(RemminaProtocolWidget *gp, RemminaMessagePanelFlags pflags, const gchar *title, const gchar *default_username, const gchar *default_password, + const gchar *default_domain, const gchar *password_prompt); gint (* protocol_plugin_init_certificate)(RemminaProtocolWidget *gp, const gchar* subject, const gchar* issuer, const gchar* fingerprint); gint (* protocol_plugin_changed_certificate)(RemminaProtocolWidget *gp, const gchar* subject, const gchar* issuer, const gchar* new_fingerprint, const gchar* old_fingerprint); gchar* (*protocol_plugin_init_get_username)(RemminaProtocolWidget * gp); diff --git a/src/include/remmina/types.h b/src/include/remmina/types.h index 71bc10ac3..f7a9e03de 100644 --- a/src/include/remmina/types.h +++ b/src/include/remmina/types.h @@ -128,6 +128,13 @@ typedef enum { RES_USE_INITIAL_WINDOW_SIZE = 2 } RemminaProtocolWidgetResolutionMode; +/* pflags field for remmina_protocol_widget_panel_auth() */ +typedef enum { + REMMINA_MESSAGE_PANEL_FLAG_USERNAME = 1, /* require username in auth panel */ + REMMINA_MESSAGE_PANEL_FLAG_DOMAIN = 2, /* require domain in auth panel */ + REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD = 4 /* require savepassword switch in auth panel */ +} RemminaMessagePanelFlags; + G_END_DECLS diff --git a/src/remmina_message_panel.h b/src/remmina_message_panel.h index 9ec0d5581..b2cdc77c1 100644 --- a/src/remmina_message_panel.h +++ b/src/remmina_message_panel.h @@ -46,11 +46,6 @@ struct _RemminaMessagePanelClass { void (* response) (RemminaMessagePanel *mp, gint response_id); }; -enum { - REMMINA_MESSAGE_PANEL_FLAG_USERNAME=1, - REMMINA_MESSAGE_PANEL_FLAG_DOMAIN=2, - REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD=4 -}; /* Widgets ID for dialog fields */ enum { diff --git a/src/remmina_plugin_manager.c b/src/remmina_plugin_manager.c index 9881ac0df..f20921c01 100644 --- a/src/remmina_plugin_manager.c +++ b/src/remmina_plugin_manager.c @@ -188,8 +188,7 @@ RemminaPluginService remmina_plugin_manager_service = remmina_protocol_widget_update_align, remmina_protocol_widget_unlock_dynres, remmina_protocol_widget_desktop_resize, - remmina_protocol_widget_panel_authpwd, - remmina_protocol_widget_panel_authuserpwd, + remmina_protocol_widget_panel_auth, remmina_protocol_widget_panel_new_certificate, remmina_protocol_widget_panel_changed_certificate, remmina_protocol_widget_get_username, diff --git a/src/remmina_protocol_widget.c b/src/remmina_protocol_widget.c index e8fbaedc5..7431472ee 100644 --- a/src/remmina_protocol_widget.c +++ b/src/remmina_protocol_widget.c @@ -103,9 +103,7 @@ struct _RemminaProtocolWidgetPriv { }; enum panel_type { - RPWDT_AUTHUSERPWD, - RPWDT_AUTHUSERPWD_SSHTUNNEL, - RPWDT_AUTHPWD, + RPWDT_AUTH, RPWDT_QUESTIONYESNO, RPWDT_AUTHX509 }; @@ -303,9 +301,12 @@ void remmina_protocol_widget_open_connection(RemminaProtocolWidget* gp) remmina_protocol_widget_open_connection_real(gp); } -static gboolean conn_closed(RemminaProtocolWidget* gp) +static gboolean conn_closed(gpointer data) { /* Close ssh tunnel */ + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; + #ifdef HAVE_LIBSSH if (gp->priv->ssh_tunnel) { remmina_ssh_tunnel_free(gp->priv->ssh_tunnel); @@ -328,9 +329,11 @@ void remmina_protocol_widget_signal_connection_closed(RemminaProtocolWidget* gp) g_idle_add(conn_closed, (gpointer)gp); } -static gboolean conn_opened(RemminaProtocolWidget* gp) +static gboolean conn_opened(gpointer data) { TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; + #ifdef HAVE_LIBSSH if (gp->priv->ssh_tunnel) { remmina_ssh_tunnel_cancel_accept(gp->priv->ssh_tunnel); @@ -356,8 +359,11 @@ void remmina_protocol_widget_signal_connection_opened(RemminaProtocolWidget* gp) g_idle_add(conn_opened, (gpointer)gp); } -static gboolean update_align(RemminaProtocolWidget* gp) +static gboolean update_align(gpointer data) { + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; + g_signal_emit_by_name(G_OBJECT(gp), "update-align"); return G_SOURCE_REMOVE; } @@ -369,8 +375,10 @@ void remmina_protocol_widget_update_align(RemminaProtocolWidget* gp) g_idle_add(update_align, (gpointer)gp); } -static gboolean unlock_dynres(RemminaProtocolWidget* gp) +static gboolean unlock_dynres(gpointer data) { + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; g_signal_emit_by_name(G_OBJECT(gp), "unlock-dynres"); return G_SOURCE_REMOVE; } @@ -382,8 +390,10 @@ void remmina_protocol_widget_unlock_dynres(RemminaProtocolWidget* gp) g_idle_add(unlock_dynres, (gpointer)gp); } -static gboolean desktop_resize(RemminaProtocolWidget* gp) +static gboolean desktop_resize(gpointer data) { + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; g_signal_emit_by_name(G_OBJECT(gp), "desktop-resize"); return G_SOURCE_REMOVE; } @@ -1121,9 +1131,13 @@ RemminaFile* remmina_protocol_widget_get_file(RemminaProtocolWidget* gp) struct remmina_protocol_widget_dialog_mt_data_t { /* Input data */ RemminaProtocolWidget *gp; - char *str1; + gchar *title; + gchar *default_username; + gchar *default_password; + gchar *default_domain; + gchar *strpasswordlabel; enum panel_type dtype; - unsigned pflags; + RemminaMessagePanelFlags pflags; gboolean called_from_subthread; /* Running status */ pthread_mutex_t pt_mutex; @@ -1132,12 +1146,12 @@ struct remmina_protocol_widget_dialog_mt_data_t { int rcbutton; }; -static void authuserpwd_mt_cb(void *user_data, int button) +static void authpanel_mt_cb(void *user_data, int button) { struct remmina_protocol_widget_dialog_mt_data_t *d = (struct remmina_protocol_widget_dialog_mt_data_t *)user_data; d->rcbutton = button; if (button == GTK_RESPONSE_OK) { - if (d->dtype == RPWDT_AUTHUSERPWD || d->dtype == RPWDT_AUTHPWD || d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL) { + if (d->dtype == RPWDT_AUTH) { d->gp->priv->password = remmina_message_panel_field_get_string(d->gp->priv->auth_message_panel, REMMINA_MESSAGE_PANEL_PASSWORD); d->gp->priv->username = remmina_message_panel_field_get_string(d->gp->priv->auth_message_panel, REMMINA_MESSAGE_PANEL_USERNAME); d->gp->priv->domain = remmina_message_panel_field_get_string(d->gp->priv->auth_message_panel, REMMINA_MESSAGE_PANEL_DOMAIN); @@ -1171,39 +1185,23 @@ static gboolean remmina_protocol_widget_dialog_mt_setup(gpointer user_data) RemminaFile* remminafile = d->gp->priv->remmina_file; RemminaMessagePanel *mp; - const gchar *key; const gchar *s; mp = remmina_message_panel_new(); - if (d->dtype == RPWDT_AUTHUSERPWD || d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL) { - remmina_message_panel_setup_auth(mp, authuserpwd_mt_cb, d, - d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL ? _("Enter SSH tunnel authentication credentials") : _("Enter authentication credentials"), - d->str1, d->pflags); - key = (d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL ? "ssh_username" : "username"); - if ((s = remmina_file_get_string(remminafile, key)) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_USERNAME, s); - if (d->dtype == RPWDT_AUTHUSERPWD && (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_DOMAIN) && (s = remmina_file_get_string(remminafile, "domain")) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_DOMAIN, s); - key = (d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL ? "ssh_password" : "password"); - if ((s = remmina_file_get_string(remminafile, key)) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_PASSWORD, s); + if (d->dtype == RPWDT_AUTH) { + remmina_message_panel_setup_auth(mp, authpanel_mt_cb, d, d->title, d->strpasswordlabel, d->pflags); + remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_USERNAME, d->default_username); + if (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_DOMAIN) + remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_DOMAIN, d->default_domain); + remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_PASSWORD, d->default_password); if (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) { - remmina_message_panel_field_set_switch(mp, REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD, FALSE); - } - } else if (d->dtype == RPWDT_AUTHPWD) { - remmina_message_panel_setup_auth(mp, authuserpwd_mt_cb, d, _("Enter authentication credentials"), d->str1, d->pflags); - if ((s = remmina_file_get_string(remminafile, "username")) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_USERNAME, s); - if ((s = remmina_file_get_string(remminafile, "password")) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_PASSWORD, s); - if (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) { - remmina_message_panel_field_set_switch(mp, REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD, FALSE); + remmina_message_panel_field_set_switch(mp, REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD, (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) ? TRUE: FALSE); } } else if (d->dtype == RPWDT_QUESTIONYESNO) { - remmina_message_panel_setup_question(mp, d->str1, authuserpwd_mt_cb, d); + remmina_message_panel_setup_question(mp, d->title, authpanel_mt_cb, d); } else if (d->dtype == RPWDT_AUTHX509) { - remmina_message_panel_setup_auth_x509(mp, authuserpwd_mt_cb, d); + remmina_message_panel_setup_auth_x509(mp, authpanel_mt_cb, d); if ((s = remmina_file_get_string(remminafile, "cacert")) != NULL) remmina_message_panel_field_set_filename(mp, REMMINA_MESSAGE_PANEL_CACERTFILE, s); if ((s = remmina_file_get_string(remminafile, "cacrl")) != NULL) @@ -1256,8 +1254,11 @@ static void run_destroy_handler (RemminaMessagePanel *mp, gpointer data) shutdown_loop(mpri); } -static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocolWidget* gp, unsigned pflags, const char *str1) +static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocolWidget* gp, RemminaMessagePanelFlags pflags, + const gchar *title, const gchar *default_username, const gchar *default_password, const gchar *default_domain, + const gchar *strpasswordlabel) { + TRACE_CALL(__func__); struct remmina_protocol_widget_dialog_mt_data_t *d = (struct remmina_protocol_widget_dialog_mt_data_t*)g_malloc( sizeof(struct remmina_protocol_widget_dialog_mt_data_t) ); int rcbutton; @@ -1265,7 +1266,11 @@ static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocol d->gp = gp; d->pflags = pflags; d->dtype = dtype; - d->str1 = g_strdup(str1); + d->title = g_strdup(title); + d->strpasswordlabel = g_strdup(strpasswordlabel); + d->default_username = g_strdup(default_username); + d->default_password = g_strdup(default_password); + d->default_domain = g_strdup(default_domain); d->called_from_subthread = FALSE; if (remmina_masterthread_exec_is_main_thread()) { @@ -1318,7 +1323,11 @@ static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocol rcbutton = d->rcbutton; } - g_free(d->str1); + g_free(d->title); + g_free(d->strpasswordlabel); + g_free(d->default_username); + g_free(d->default_password); + g_free(d->default_domain); g_free(d); return rcbutton; @@ -1326,27 +1335,15 @@ static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocol gint remmina_protocol_widget_panel_question_yesno(RemminaProtocolWidget* gp, const char *msg) { - return remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, msg); + return remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, msg, NULL, NULL, NULL, NULL); } -gint remmina_protocol_widget_panel_authuserpwd(RemminaProtocolWidget* gp, gboolean want_domain, gboolean allow_password_saving) +gint remmina_protocol_widget_panel_auth(RemminaProtocolWidget* gp, RemminaMessagePanelFlags pflags, + const gchar *title, const gchar *default_username, const gchar *default_password, const gchar *default_domain, const gchar *password_prompt) { TRACE_CALL(__func__); - unsigned pflags; - RemminaFile* remminafile = gp->priv->remmina_file; - - pflags = REMMINA_MESSAGE_PANEL_FLAG_USERNAME; - g_debug ("pflags is %u", pflags); - if (remmina_file_get_filename(remminafile) != NULL && - !remminafile->prevent_saving && allow_password_saving) - pflags |= REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD; - g_debug ("pflags is %u", pflags); - if (want_domain) - pflags |= REMMINA_MESSAGE_PANEL_FLAG_DOMAIN; - - g_debug ("pflags is %u", pflags); - - return remmina_protocol_widget_dialog(RPWDT_AUTHUSERPWD, gp, pflags, _("Password")); + return remmina_protocol_widget_dialog(RPWDT_AUTH, gp, pflags, title, default_username, + default_password, default_domain, password_prompt == NULL ? _("Password") : password_prompt); } gint remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(RemminaProtocolWidget* gp, gboolean want_domain, gboolean allow_password_saving) @@ -1354,15 +1351,21 @@ gint remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(RemminaProtocolWidget* TRACE_CALL(__func__); unsigned pflags; RemminaFile* remminafile = gp->priv->remmina_file; + const gchar *username, *password; pflags = REMMINA_MESSAGE_PANEL_FLAG_USERNAME; if (remmina_file_get_filename(remminafile) != NULL && !remminafile->prevent_saving && allow_password_saving) pflags |= REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD; - return remmina_protocol_widget_dialog(RPWDT_AUTHUSERPWD_SSHTUNNEL, gp, pflags, _("Password")); + username = remmina_file_get_string(remminafile, "ssh_username"); + password = remmina_file_get_string(remminafile, "ssh_password"); + + return remmina_protocol_widget_dialog(RPWDT_AUTH, gp, pflags, _("Enter SSH tunnel authentication credentials"), username, + password, NULL, _("Password")); } +/* gint remmina_protocol_widget_panel_authpwd(RemminaProtocolWidget* gp, RemminaAuthpwdType authpwd_type, gboolean allow_password_saving) { TRACE_CALL(__func__); @@ -1391,17 +1394,18 @@ gint remmina_protocol_widget_panel_authpwd(RemminaProtocolWidget* gp, RemminaAut break; } - rc = remmina_protocol_widget_dialog(RPWDT_AUTHPWD, gp, pflags, password_prompt); + rc = remmina_protocol_widget_dialog(RPWDT_AUTH, gp, pflags, password_prompt); g_free(password_prompt); return rc; } +*/ gint remmina_protocol_widget_panel_authx509(RemminaProtocolWidget* gp) { TRACE_CALL(__func__); - return remmina_protocol_widget_dialog(RPWDT_AUTHX509, gp, 0, NULL); + return remmina_protocol_widget_dialog(RPWDT_AUTHX509, gp, 0, NULL, NULL, NULL, NULL, NULL); } @@ -1419,7 +1423,7 @@ gint remmina_protocol_widget_panel_new_certificate(RemminaProtocolWidget* gp, co _("Issuer:"), issuer, _("Fingerprint:"), fingerprint, _("Accept Certificate?")); - rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s); + rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s, NULL, NULL, NULL, NULL); g_free(s); /* For compatibility with plugin API: the plugin expects GTK_RESPONSE_OK when user confirms new cert */ @@ -1439,10 +1443,10 @@ gint remmina_protocol_widget_panel_changed_certificate(RemminaProtocolWidget *gp _("The certificate changed! Details:"), _("Subject:"), subject, _("Issuer:"), issuer, - _("Old fingerprint:"), old_fingerprint, - _("New fingerprint:"), new_fingerprint, - _("Accept changed certificate?")); - rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s); + _("Old Fingerprint:"), old_fingerprint, + _("New Fingerprint:"), new_fingerprint, + _("Accept Changed Certificate?")); + rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s, NULL, NULL, NULL, NULL); g_free(s); /* For compatibility with plugin API: The plugin expects GTK_RESPONSE_OK when user confirms new cert */ diff --git a/src/remmina_protocol_widget.h b/src/remmina_protocol_widget.h index 566f6d94b..2108464f6 100644 --- a/src/remmina_protocol_widget.h +++ b/src/remmina_protocol_widget.h @@ -130,8 +130,7 @@ gint remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(RemminaProtocolWidget* /* Dialog panel API used by the plugins */ -gint remmina_protocol_widget_panel_authpwd(RemminaProtocolWidget *gp, RemminaAuthpwdType authpwd_type, gboolean allow_password_saving); -gint remmina_protocol_widget_panel_authuserpwd(RemminaProtocolWidget *gp, gboolean want_domain, gboolean allow_password_saving); +gint remmina_protocol_widget_panel_auth(RemminaProtocolWidget* gp, RemminaMessagePanelFlags pflags, const gchar *title, const gchar *default_username, const gchar *default_password, const gchar *default_domain, const gchar *password_prompt); gint remmina_protocol_widget_panel_new_certificate(RemminaProtocolWidget* gp, const gchar* subject, const gchar* issuer, const gchar* fingerprint); gint remmina_protocol_widget_panel_changed_certificate(RemminaProtocolWidget *gp, const gchar* subject, const gchar* issuer, const gchar* new_fingerprint, const gchar* old_fingerprint); gint remmina_protocol_widget_panel_question_yesno(RemminaProtocolWidget* gp, const char *msg); diff --git a/src/remmina_ssh.c b/src/remmina_ssh.c index 2a8a8c874..b2e56fe98 100644 --- a/src/remmina_ssh.c +++ b/src/remmina_ssh.c @@ -265,24 +265,26 @@ remmina_ssh_auth_auto_pubkey(RemminaSSH *ssh, RemminaProtocolWidget *gp, Remmina gboolean disablepasswordstoring; gboolean save_password; gchar *pwd; - gchar *pwdtype = "ssh_passphrase"; gint ret; if (!ssh->passphrase) { disablepasswordstoring = remmina_file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_protocol_widget_panel_authpwd(gp, REMMINA_AUTHPWD_TYPE_SSH_PRIVKEY, !disablepasswordstoring); - save_password = remmina_protocol_widget_get_savepassword(gp); + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD), + _("SSH credentials"), NULL, + remmina_file_get_string(remminafile, "ssh_privatekey"), + NULL, + _("SSH private key passphrase")); if (ret == GTK_RESPONSE_OK) { - if (save_password) { - pwd = remmina_protocol_widget_get_password(gp); - remmina_file_set_string(remminafile, pwdtype, pwd); - g_free(pwd); - } - } else { + pwd = remmina_protocol_widget_get_password(gp); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "ssh_passphrase", pwd); + else + remmina_file_set_string(remminafile, "ssh_passphrase", NULL); + } else return -1; - } - ssh->passphrase = remmina_protocol_widget_get_password(gp); + ssh->passphrase = pwd; } ret = ssh_userauth_publickey_auto(ssh->session, NULL, ssh->passphrase); @@ -498,23 +500,63 @@ remmina_ssh_auth_gui(RemminaSSH *ssh, RemminaProtocolWidget *gp, RemminaFile *re disablepasswordstoring = remmina_file_get_int(remminafile, "disablepasswordstoring", FALSE); - if (g_strcmp0(pwdtype, "ssh_passphrase") == 0) - ret = remmina_protocol_widget_panel_authpwd(gp, REMMINA_AUTHPWD_TYPE_SSH_PRIVKEY, !disablepasswordstoring); - else if (g_strcmp0(pwdtype, "ssh_password") == 0) - ret = remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(gp, FALSE, !disablepasswordstoring); - else - ret = remmina_protocol_widget_panel_authuserpwd(gp, FALSE, !disablepasswordstoring); - save_password = remmina_protocol_widget_get_savepassword(gp); - - if (ret == GTK_RESPONSE_OK) { - if (save_password) { + if (g_strcmp0(pwdtype, "ssh_passphrase") == 0) { + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD), + _("SSH credentials"), NULL, + remmina_file_get_string(remminafile, "ssh_privatekey"), + NULL, + _("SSH private key passphrase")); + if (ret == GTK_RESPONSE_OK) { pwd = remmina_protocol_widget_get_password(gp); - remmina_file_set_string(remminafile, pwdtype, pwd); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "ssh_passphrase", pwd); + else + remmina_file_set_string(remminafile, "ssh_passphrase", NULL); g_free(pwd); - } + } else return -1; + } else if (g_strcmp0(pwdtype, "ssh_password") == 0) { + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME, + _("SSH tunnel credentials"), + remmina_file_get_string(remminafile, "ssh_username"), + remmina_file_get_string(remminafile, "ssh_password"), + NULL, + NULL); + if (ret == GTK_RESPONSE_OK) { + pwd = remmina_protocol_widget_get_username(gp); + remmina_file_set_string(remminafile, "username", pwd); + g_free(pwd); + pwd = remmina_protocol_widget_get_password(gp); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "ssh_password", pwd); + else + remmina_file_set_string(remminafile, "ssh_password", NULL); + g_free(pwd); + } else + return -1; } else { - return -1; + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME, + _("SSH credentials"), + remmina_file_get_string(remminafile, "username"), + remmina_file_get_string(remminafile, "password"), + NULL, + NULL); + if (ret == GTK_RESPONSE_OK) { + pwd = remmina_protocol_widget_get_username(gp); + remmina_file_set_string(remminafile, "username", pwd); + g_free(pwd); + pwd = remmina_protocol_widget_get_password(gp); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "password", pwd); + else + remmina_file_set_string(remminafile, "password", NULL); + g_free(pwd); + } else + return -1; } + pwd = remmina_protocol_widget_get_password(gp); ret = remmina_ssh_auth(ssh, pwd, gp, remminafile); g_free(pwd); |