diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2021-06-02 00:35:44 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2021-06-02 00:35:44 +0300 |
commit | 475baf48221817295323fc919f1f6d003fc6caf7 (patch) | |
tree | fefa49a194834112c9723ebc0492247337271619 /src/remmina_ssh_plugin.c | |
parent | e6b3e16eef5798c54862594ee3ecc3fbb10f029e (diff) |
Save SSH session when closing, fixes #2512
Diffstat (limited to 'src/remmina_ssh_plugin.c')
-rw-r--r-- | src/remmina_ssh_plugin.c | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/src/remmina_ssh_plugin.c b/src/remmina_ssh_plugin.c index b25c8fee5..218f3641d 100644 --- a/src/remmina_ssh_plugin.c +++ b/src/remmina_ssh_plugin.c @@ -860,6 +860,43 @@ void remmina_plugin_ssh_popup_ui(RemminaProtocolWidget *gp) gtk_widget_show_all(menu); } +static gboolean +remmina_plugin_ssh_close_connection(RemminaProtocolWidget *gp) +{ + TRACE_CALL(__func__); + RemminaPluginSshData *gpdata = GET_PLUGIN_DATA(gp); + + RemminaFile *remminafile; + + REMMINA_DEBUG("Requesting to close the connection"); + remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); + + if (remmina_file_get_int(remminafile, "sshlogenabled", FALSE)) + remmina_plugin_ssh_vte_save_session(NULL, gp); + if (gpdata->thread) { + pthread_cancel(gpdata->thread); + if (gpdata->thread) pthread_join(gpdata->thread, NULL); + } + if (gpdata->shell) { + remmina_ssh_shell_free(gpdata->shell); + gpdata->shell = NULL; + } + + remmina_plugin_service->protocol_plugin_signal_connection_closed(gp); + return FALSE; +} + +static void +remmina_plugin_ssh_eof(VteTerminal *vteterminal, RemminaProtocolWidget *gp) +{ + TRACE_CALL(__func__); + + RemminaFile *remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); + + if (remmina_file_get_int(remminafile, "sshlogenabled", FALSE)) + remmina_plugin_ssh_vte_save_session(NULL, gp); +} + /** * Remmina SSH plugin initialization. * @@ -1172,7 +1209,6 @@ remmina_plugin_ssh_init(RemminaProtocolWidget *gp) gtk_box_pack_start(GTK_BOX(hbox), vte, TRUE, TRUE, 0); gpdata->vte = vte; remmina_plugin_ssh_set_vte_pref(gp); - g_signal_connect(G_OBJECT(vte), "size-allocate", G_CALLBACK(remmina_plugin_ssh_on_size_allocate), gp); remmina_plugin_service->protocol_plugin_register_hostkey(gp, vte); @@ -1208,6 +1244,10 @@ remmina_plugin_ssh_init(RemminaProtocolWidget *gp) fp = g_strconcat(dir, "/", sshlogname, NULL); gpdata->vte_session_file = g_file_new_for_path(fp); + g_signal_connect(G_OBJECT(vte), "size-allocate", G_CALLBACK(remmina_plugin_ssh_on_size_allocate), gp); + g_signal_connect (G_OBJECT(vte), "unrealize", G_CALLBACK(remmina_plugin_ssh_eof), gp); + g_signal_connect (G_OBJECT(vte), "eof", G_CALLBACK(remmina_plugin_ssh_eof), gp); + g_signal_connect (G_OBJECT(vte), "child-exited", G_CALLBACK(remmina_plugin_ssh_eof), gp); remmina_plugin_ssh_popup_ui(gp); gtk_widget_show_all(hbox); } @@ -1240,31 +1280,6 @@ remmina_plugin_ssh_open_connection(RemminaProtocolWidget *gp) return TRUE; } -static gboolean -remmina_plugin_ssh_close_connection(RemminaProtocolWidget *gp) -{ - TRACE_CALL(__func__); - RemminaPluginSshData *gpdata = GET_PLUGIN_DATA(gp); - - RemminaFile *remminafile; - - remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); - - if (remmina_file_get_int(remminafile, "sshlogenabled", FALSE)) - remmina_plugin_ssh_vte_save_session(NULL, gp); - if (gpdata->thread) { - pthread_cancel(gpdata->thread); - if (gpdata->thread) pthread_join(gpdata->thread, NULL); - } - if (gpdata->shell) { - remmina_ssh_shell_free(gpdata->shell); - gpdata->shell = NULL; - } - - remmina_plugin_service->protocol_plugin_signal_connection_closed(gp); - return FALSE; -} - /** * Not used by the plugin. * |