Commit 0faf245b authored by Antenore Gatta's avatar Antenore Gatta

Feature Request: After Command #746

parent 24cdef41
......@@ -77,8 +77,8 @@ set(REMMINA_SRCS
src/remmina_masterthread_exec.h
src/remmina_plugin_manager.c
src/remmina_plugin_manager.h
src/remmina_preexec.c
src/remmina_preexec.h
src/remmina_plugin_cmdexec.c
src/remmina_plugin_cmdexec.h
src/remmina_pref.c
src/remmina_pref_dialog.c
src/remmina_pref_dialog.h
......
......@@ -33,23 +33,25 @@
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <stdlib.h>
#include "config.h"
#include "remmina_public.h"
#include "remmina_connection_window.h"
#include "remmina_file.h"
#include "remmina_file_manager.h"
#include "remmina_init_dialog.h"
#include "remmina_protocol_widget.h"
#include "remmina_plugin_cmdexec.h"
#include "remmina_plugin_manager.h"
#include "remmina_pref.h"
#include "remmina_preexec.h"
#include "remmina_protocol_widget.h"
#include "remmina_public.h"
#include "remmina_scrolled_viewport.h"
#include "remmina_widget_pool.h"
#include "remmina_connection_window.h"
#include "remmina/remmina_trace_calls.h"
#include "remmina_plugin_manager.h"
G_DEFINE_TYPE( RemminaConnectionWindow, remmina_connection_window, GTK_TYPE_WINDOW)
......@@ -3319,7 +3321,7 @@ remmina_connection_window_open_from_file_full(RemminaFile* remminafile, GCallbac
cnnobj->remmina_file = remminafile;
/* Exec precommand before everything else */
remmina_preexec_new(cnnobj->remmina_file);
remmina_plugin_cmdexec_new(cnnobj->remmina_file, "precommand");
/* Create the RemminaProtocolWidget */
cnnobj->proto = remmina_protocol_widget_new();
......
......@@ -97,6 +97,7 @@ struct _RemminaFileEditorPriv
GtkWidget* group_combo;
GtkWidget* protocol_combo;
GtkWidget* precommand_entry;
GtkWidget* postcommand_entry;
GtkWidget* save_button;
GtkWidget* config_box;
......@@ -1115,6 +1116,7 @@ static void remmina_file_editor_update(RemminaFileEditor* gfe)
remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->protocol_combo)));
remmina_file_set_string(priv->remmina_file, "precommand", gtk_entry_get_text(GTK_ENTRY(priv->precommand_entry)));
remmina_file_set_string(priv->remmina_file, "postcommand", gtk_entry_get_text(GTK_ENTRY(priv->postcommand_entry)));
remmina_file_set_string_ref(priv->remmina_file, "server",
(priv->server_combo ? remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->server_combo)) : NULL));
......@@ -1160,6 +1162,7 @@ static void remmina_file_editor_on_default(GtkWidget* button, RemminaFileEditor*
remmina_file_set_string(gf, "server", NULL);
remmina_file_set_string(gf, "password", NULL);
remmina_file_set_string(gf, "precommand", NULL);
remmina_file_set_string(gf, "postcommand", NULL);
remmina_file_save_all(gf);
remmina_file_free(gf);
......@@ -1409,6 +1412,28 @@ GtkWidget* remmina_file_editor_new_from_file(RemminaFile* remminafile)
g_free(s);
}
/* POST Connection Command */
widget = gtk_label_new(_("Post Command"));
gtk_widget_show(widget);
gtk_widget_set_valign (widget, GTK_ALIGN_START);
gtk_widget_set_halign (widget, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(grid), widget, 0, 15, 3, 1);
gtk_grid_set_column_spacing (GTK_GRID(grid), 10);
widget = gtk_entry_new();
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 15, 3, 1);
gtk_entry_set_max_length(GTK_ENTRY(widget), 200);
priv->postcommand_entry = widget;
cs = remmina_file_get_string(remminafile, "postcommand");
gtk_entry_set_text(GTK_ENTRY(widget), cs ? cs : "");
if (!cs)
{
s = g_strdup_printf(_("A command or a script name/path."));
gtk_widget_set_tooltip_text (widget, s);
g_free(s);
}
/* Create the Preference frame */
widget = gtk_event_box_new();
gtk_widget_show(widget);
......
......@@ -39,7 +39,7 @@
#include <stdlib.h>
#include <sys/wait.h>
#include "remmina_file.h"
#include "remmina_preexec.h"
#include "remmina_plugin_cmdexec.h"
#include "remmina_public.h"
#include "remmina/remmina_trace_calls.h"
......@@ -56,21 +56,34 @@ static void wait_for_child(GPid pid, gint script_retval, gpointer data)
g_free(pcspinner);
}
GtkDialog* remmina_preexec_new(RemminaFile* remminafile)
GtkDialog* remmina_plugin_cmdexec_new(RemminaFile* remminafile, const char *remmina_plugin_cmdexec_type)
{
TRACE_CALL("remmina_preexec_new");
TRACE_CALL("remmina_plugin_cmdexec_new");
GtkBuilder *builder;
PCon_Spinner *pcspinner;
GError *error = NULL;
char **argv;
char const *plugin_cmd = NULL;
gchar pre[9];
gchar post[9];
char const *cmd = NULL;
char const *precmd = NULL;
GPid child_pid;
precmd = remmina_file_get_string(remminafile, "precommand");
if (precmd)
strcpy(pre, "precommand");
strcpy(post, "postcommand");
if (remmina_plugin_cmdexec_type != NULL && (
strcmp(remmina_plugin_cmdexec_type, pre) |
strcmp(remmina_plugin_cmdexec_type, post) ))
{
plugin_cmd = remmina_file_get_string(remminafile, remmina_plugin_cmdexec_type);
}else{
return FALSE;
}
if (plugin_cmd != NULL)
{
cmd = g_shell_quote(remmina_file_get_string(remminafile, "precommand"));
cmd = g_shell_quote(remmina_file_get_string(remminafile, remmina_plugin_cmdexec_type));
pcspinner = g_new(PCon_Spinner, 1);
builder = remmina_public_gtk_builder_new_from_file("remmina_spinner.glade");
pcspinner->dialog = GTK_DIALOG(gtk_builder_get_object(builder, "DialogSpinner"));
......
......@@ -46,7 +46,7 @@ typedef struct
GtkWidget *spinner;
} PCon_Spinner;
GtkDialog* remmina_preexec_new(RemminaFile* remminafile);
GtkDialog* remmina_plugin_cmdexec_new(RemminaFile* remminafile, const char *remmina_plugin_cmdexec_type);
G_END_DECLS
......
......@@ -33,21 +33,24 @@
*
*/
#include "config.h"
#include <gtk/gtk.h>
#if GTK_VERSION == 3
# include <gtk/gtkx.h>
#endif
#include <glib/gi18n.h>
#include <stdlib.h>
#include "config.h"
#include "remmina_public.h"
#include "remmina_pref.h"
#include "remmina_ssh.h"
#include "remmina_chat_window.h"
#include "remmina_plugin_manager.h"
#include "remmina_connection_window.h"
#include "remmina_protocol_widget.h"
#include "remmina_masterthread_exec.h"
#include "remmina_plugin_cmdexec.h"
#include "remmina_plugin_manager.h"
#include "remmina_pref.h"
#include "remmina_protocol_widget.h"
#include "remmina_public.h"
#include "remmina_ssh.h"
#include "remmina/remmina_trace_calls.h"
struct _RemminaProtocolWidgetPriv
......@@ -328,6 +331,8 @@ gboolean remmina_protocol_widget_close_connection(RemminaProtocolWidget* gp)
}
#endif
/* Exec postcommand before to close the connection */
remmina_plugin_cmdexec_new(gp->priv->remmina_file, "postcommand");
return retval;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment