Commit 580bf1eb authored by Giovanni Panozzo's avatar Giovanni Panozzo

External tools call fixup, fixes #385

parent c8bf15ed
......@@ -170,6 +170,10 @@ endif()
if(WITH_TRANSLATIONS)
add_subdirectory(po)
endif()
set(REMMINA_EXTERNAL_TOOLS_DIR "${CMAKE_INSTALL_FULL_DATADIR}/remmina/external_tools")
add_definitions( -DREMMINA_EXTERNAL_TOOLS_DIR="${REMMINA_EXTERNAL_TOOLS_DIR}" )
add_subdirectory(icons)
add_subdirectory(desktop)
add_subdirectory(external_tools)
......@@ -180,3 +184,5 @@ install(DIRECTORY include/remmina/ DESTINATION include/remmina FILES_MATCHING PA
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/remmina.pc.in ${CMAKE_CURRENT_BINARY_DIR}/remmina.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/remmina.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
......@@ -30,7 +30,6 @@
# version. If you delete this exception statement from all source
# files in the program, then also delete it here.
set(EXTERNAL_TOOLS_DIR "${CMAKE_INSTALL_FULL_DATADIR}/remmina/external_tools")
INSTALL(PROGRAMS launcher.sh functions.sh remmina_filezilla_sftp.sh remmina_filezilla_sftp_pki.sh remmina_nslookup.sh remmina_ping.sh remmina_traceroute.sh DESTINATION ${REMMINA_EXTERNAL_TOOLS_DIR})
INSTALL(PROGRAMS launcher.sh pause.sh remmina_filezilla_sftp.sh remmina_filezilla_sftp_pki.sh remmina_nslookup.sh remmina_ping.sh remmina_traceroute.sh DESTINATION ${EXTERNAL_TOOLS_DIR})
......@@ -9,3 +9,9 @@ pause ()
dd count=1 2>/dev/null
stty $OLDCONFIG
}
# set terminal title for gnome-terminal and many others
settitle() {
echo -ne "\033]0;${remmina_term_title}\007"
}
......@@ -3,8 +3,15 @@
####################
# Main Script
####################
#gnome-terminal -e $(dirname $0)/$1
gnome-terminal -e $1 &
#gnome-terminal -e $(dirname $0)/$1
if [ -x "/usr/bin/x-terminal-emulator" ];
then
TERMNAME="/usr/bin/x-terminal-emulator"
else
TERMNAME="gnome-terminal"
fi
$TERMNAME -e "$1" &
#if [ "$2" = "1" ]
#then
......
#!/bin/sh
. $(dirname $0)/pause.sh
. $(dirname $0)/functions.sh
settitle
filezilla sftp://$ssh_username:$password@$server
#!/bin/sh
. $(dirname $0)/pause.sh
. $(dirname $0)/functions.sh
settitle
filezilla sftp://$ssh_username@$server
#!/bin/sh
. $(dirname $0)/pause.sh
. $(dirname $0)/functions.sh
settitle
nslookup $server
......
#!/bin/sh
. $(dirname $0)/pause.sh
. $(dirname $0)/functions.sh
settitle
ping -c3 $server
......
#!/bin/sh
. $(dirname $0)/pause.sh
. $(dirname $0)/functions.sh
settitle
traceroute $server
......
......@@ -45,8 +45,11 @@ typedef struct _RemminaExternalTools
{
gchar remminafilename[MAX_PATH_LEN];
gchar scriptfilename[MAX_PATH_LEN];
gchar scriptshortname[MAX_PATH_LEN];
} RemminaExternalTools;
static gboolean remmina_external_tools_launcher(const gchar* filename, const gchar* scriptname, const gchar* shortname);
void view_popup_menu_onDoSomething (GtkWidget *menuitem, gpointer userdata)
{
TRACE_CALL("view_popup_menu_onDoSomething");
......@@ -55,7 +58,7 @@ void view_popup_menu_onDoSomething (GtkWidget *menuitem, gpointer userdata)
//gchar* filename_remmina = ret->remminafilename;
//gchar* filename_script = ret->scriptfilename;
remmina_external_tools_launcher(ret->remminafilename,ret->scriptfilename);
remmina_external_tools_launcher(ret->remminafilename, ret->scriptfilename, ret->scriptshortname);
}
gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* remminafilename)
......@@ -70,7 +73,7 @@ gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* re
GNode* root;
root = g_node_new(NULL);
g_snprintf(dirname, MAX_PATH_LEN, "%s/.remmina/external_tools", g_get_home_dir());
strcpy(dirname, REMMINA_EXTERNAL_TOOLS_DIR);
dir = g_dir_open(dirname, 0, NULL);
if (dir == NULL)
......@@ -85,6 +88,7 @@ gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* re
ret = (RemminaExternalTools *)malloc(sizeof(RemminaExternalTools));
strcpy(ret->remminafilename,remminafilename);
strcpy(ret->scriptfilename,filename);
strcpy(ret->scriptshortname,name);
menuitem = gtk_menu_item_new_with_label(strndup(name + 8, strlen(name) -8));
g_signal_connect(menuitem, "activate", (GCallback) view_popup_menu_onDoSomething, ret);
......@@ -105,12 +109,16 @@ gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* re
return TRUE;
}
gboolean remmina_external_tools_launcher(const gchar* filename,const gchar* scriptname)
static gboolean remmina_external_tools_launcher(const gchar* filename, const gchar* scriptname, const gchar* shortname)
{
TRACE_CALL("remmina_external_tools_launcher");
RemminaFile *remminafile;
const char *env_format = "%s=%s";
char *env;
size_t envstrlen;
gchar launcher[MAX_PATH_LEN];
g_snprintf(launcher, MAX_PATH_LEN, "%s/.remmina/external_tools/launcher.sh", g_get_home_dir());
g_snprintf(launcher, MAX_PATH_LEN, "%s/launcher.sh", REMMINA_EXTERNAL_TOOLS_DIR);
remminafile = remmina_file_load(filename);
GHashTableIter iter;
......@@ -118,30 +126,47 @@ gboolean remmina_external_tools_launcher(const gchar* filename,const gchar* scri
g_hash_table_iter_init(&iter, remminafile->settings);
while (g_hash_table_iter_next(&iter, (gpointer*) &key, (gpointer*) &value))
{
const char *env_format = "%s=%s";
const size_t len = strlen(key) +strlen(value) + strlen(env_format);
char *env = (char *) malloc(len);
envstrlen = strlen(key) +strlen(value) + strlen(env_format) + 1;
env = (char *) malloc(envstrlen);
if (env == NULL)
{
return -1;
}
int retval = snprintf(env, len, env_format, key,value);
if (retval < 0 || (size_t) retval >= len)
int retval = snprintf(env, envstrlen, env_format, key,value);
if (retval > 0 && (size_t) retval <= envstrlen)
{
/* Handle error */
if (putenv(env) !=0)
{
/* If putenv fails, we must free the unused space */
free(env);
}
}
if (putenv(env) != 0)
}
/* Adds the window title for the terminal window */
const char *term_title_key = "remmina_term_title";
const char *term_title_val_prefix = "Remmina external tool";
envstrlen = strlen(term_title_key) + strlen(term_title_val_prefix) + strlen(shortname) + 7;
env = (char *) malloc(envstrlen);
if (env != NULL)
{
if (snprintf(env, envstrlen, "%s=%s: %s", term_title_key, term_title_val_prefix, shortname) )
{
free(env);
if (putenv(env) != 0)
{
/* If putenv fails, we must free the unused space */
free(env);
}
}
}
const size_t cmdlen = strlen(launcher) +strlen(scriptname) + 2;
gchar *cmd = (gchar *)malloc(cmdlen);
g_snprintf(cmd, cmdlen, "%s %s", launcher, scriptname);
system(cmd);
free(cmd);
remmina_file_free(remminafile);
return TRUE;
}
......@@ -43,7 +43,6 @@ G_BEGIN_DECLS
/* Open a new connection window for a .remmina file */
gboolean remmina_external_tools_from_filename(RemminaMain *remminamain,gchar* filename);
gboolean remmina_external_tools_launcher(const gchar* filename,const gchar* scriptname);
G_END_DECLS
......
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