Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntenore Gatta <antenore@simbiosi.org>2015-04-20 02:55:11 +0300
committerAntenore Gatta <antenore@simbiosi.org>2015-04-20 02:55:11 +0300
commitef5d07a88f5eab18fefcee702e9c58c5706e27b9 (patch)
tree7ad5f62ff651ae9cd47e4025521dbd52ba8b5edf
parent8e87ca1e2c130cd263014ab431cb916f1f7fe527 (diff)
Add function to execute a predefined command just before the connection initialisation, working on #520 and #553
-rw-r--r--remmina/src/remmina_preexec.c108
-rw-r--r--remmina/src/remmina_preexec.h45
-rw-r--r--remmina/ui/CMakeLists.txt1
-rw-r--r--remmina/ui/remmina_spinner.glade80
4 files changed, 234 insertions, 0 deletions
diff --git a/remmina/src/remmina_preexec.c b/remmina/src/remmina_preexec.c
new file mode 100644
index 000000000..6a3ed1e7d
--- /dev/null
+++ b/remmina/src/remmina_preexec.c
@@ -0,0 +1,108 @@
+/*
+ * Remmina - The GTK+ Remote Desktop Client
+ * Copyright (C) 2009-2010 Vic Lee
+ * Copyright (C) 2014-2015 Antenore Gatta, Giovanni Panozzo
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of portions of this program with the
+ * OpenSSL library under certain conditions as described in each
+ * individual source file, and distribute linked combinations
+ * including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. * If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. * If you
+ * do not wish to do so, delete this exception statement from your
+ * version. * If you delete this exception statement from all source
+ * files in the program, then also delete it here.
+ *
+ */
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include "remmina_file.h"
+#include "remmina_preexec.h"
+#include "remmina_public.h"
+#include "remmina/remmina_trace_calls.h"
+
+#define GET_OBJECT(object_name) gtk_builder_get_object(builder, object_name)
+
+void child_watch (GPid pid, gint status, gpointer user_data)
+{
+ gboolean ok;
+
+ /* Successful program termination is determined by the EXIT_SUCCESS code.
+ * Otherwise it is considered to have terminated abnormally.
+ */
+ if (WIFEXITED (status) && WEXITSTATUS (status) == EXIT_SUCCESS)
+ ok = TRUE;
+ else
+ ok = FALSE;
+
+ g_debug ("client_os_command: child exited %s", ok ? "OK" : "FAIL");
+}
+
+GtkDialog* remmina_preexec_new(RemminaFile* remminafile)
+{
+ TRACE_CALL("remmina_preexec_new");
+ GtkBuilder *builder;
+ GtkDialog *dialog;
+ GtkLabel *label_pleasewait;
+ GtkWidget *spinner;
+ GtkButton *button_cancel;
+ GError *error = NULL;
+ char **argv;
+ gint argp;
+ char const *cmd = NULL;
+ gboolean ok, watch;
+ GPid child_pid;
+
+ cmd = remmina_file_get_string(remminafile, "precommand");
+ ok = g_shell_parse_argv(cmd, &argp, &argv, NULL);
+
+ g_assert(ok==TRUE);
+ if (cmd)
+ {
+ builder = remmina_public_gtk_builder_new_from_file("remmina_spinner.glade");
+ dialog = GTK_DIALOG(gtk_builder_get_object(builder, "DialogSpinner"));
+ label_pleasewait = GTK_LABEL(GET_OBJECT("label_pleasewait"));
+ spinner = GTK_WIDGET(GET_OBJECT("spinner"));
+ button_cancel = GTK_BUTTON(GET_OBJECT("button_cancel"));
+ /* gtk_window_set_transient_for(GTK_WINDOW(dialog), parent_window); */
+ /* Connect signals */
+ gtk_builder_connect_signals(builder, NULL);
+
+ /* Exec a predefined command */
+ g_spawn_async( NULL, // cwd
+ argv, // argv
+ NULL, // envp
+ G_SPAWN_DO_NOT_REAP_CHILD, // flags
+ NULL, // child_setup
+ NULL, // child_setup user data
+ &child_pid, // exit status
+ &error); // error
+ if (error)
+ g_warning ("%s", error->message);
+ gtk_spinner_start (GTK_SPINNER (spinner));
+ g_assert(watch==FALSE);
+ gtk_spinner_stop(GTK_SPINNER (spinner));
+ gtk_dialog_run(dialog);
+ }
+}
diff --git a/remmina/src/remmina_preexec.h b/remmina/src/remmina_preexec.h
new file mode 100644
index 000000000..d77e321cb
--- /dev/null
+++ b/remmina/src/remmina_preexec.h
@@ -0,0 +1,45 @@
+/*
+ * Remmina - The GTK+ Remote Desktop Client
+ * Copyright (C) 2009-2010 Vic Lee
+ * Copyright (C) 2014-2015 Antenore Gatta, Giovanni Panozzo
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of portions of this program with the
+ * OpenSSL library under certain conditions as described in each
+ * individual source file, and distribute linked combinations
+ * including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. * If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. * If you
+ * do not wish to do so, delete this exception statement from your
+ * version. * If you delete this exception statement from all source
+ * files in the program, then also delete it here.
+ *
+ */
+
+#ifndef __REMMINAPREEXEC_H__
+#define __REMMINAPREEXEC_H__
+
+G_BEGIN_DECLS
+
+GtkDialog* remmina_preexec_new(RemminaFile* remminafile);
+
+G_END_DECLS
+
+#endif /* __REMMINAPREEXEC_H__ */
diff --git a/remmina/ui/CMakeLists.txt b/remmina/ui/CMakeLists.txt
index ac770c371..0bde13810 100644
--- a/remmina/ui/CMakeLists.txt
+++ b/remmina/ui/CMakeLists.txt
@@ -33,6 +33,7 @@
install(FILES remmina_about.glade DESTINATION "${REMMINA_UIDIR}")
install(FILES remmina_main.glade DESTINATION "${REMMINA_UIDIR}")
+install(FILES remmina_spinner.glade DESTINATION "${REMMINA_UIDIR}")
install(FILES remmina_preferences.glade DESTINATION "${REMMINA_UIDIR}")
install(FILES remmina_key_chooser.glade DESTINATION "${REMMINA_UIDIR}")
install(FILES remmina_string_list.glade DESTINATION "${REMMINA_UIDIR}")
diff --git a/remmina/ui/remmina_spinner.glade b/remmina/ui/remmina_spinner.glade
new file mode 100644
index 000000000..6b5ff4b45
--- /dev/null
+++ b/remmina/ui/remmina_spinner.glade
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.0"/>
+ <object class="GtkActionGroup" id="actiongroup_actions">
+ <child>
+ <object class="GtkAction" id="action_cancel">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="short_label" translatable="yes">_Cancel</property>
+ </object>
+ </child>
+ </object>
+ <object class="GtkDialog" id="DialogSpinner">
+ <property name="can_focus">False</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <property name="homogeneous">True</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button_cancel">
+ <property name="label" translatable="yes">button</property>
+ <property name="use_action_appearance">True</property>
+ <property name="related_action">action_cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="xalign">0.57999998331069946</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_pleasewait">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">PLEASE WAIT ...</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="active">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">button_cancel</action-widget>
+ </action-widgets>
+ </object>
+</interface>