Ejemplo n.º 1
0
gboolean
remmina_ssh_init_from_file (RemminaSSH *ssh, RemminaFile *remminafile)
{
	const gchar *ssh_server;
	const gchar *ssh_username;
	const gchar *ssh_privatekey;
	const gchar *server;
	gchar *s;

	ssh->session = NULL;
	ssh->callback = NULL;
	ssh->authenticated = FALSE;
	ssh->error = NULL;
	pthread_mutex_init (&ssh->ssh_mutex, NULL);

	/* Parse the address and port */
	ssh_server = remmina_file_get_string (remminafile, "ssh_server");
	ssh_username = remmina_file_get_string (remminafile, "ssh_username");
	ssh_privatekey = remmina_file_get_string (remminafile, "ssh_privatekey");
	server = remmina_file_get_string (remminafile, "server");
	if (ssh_server)
	{
		remmina_public_get_server_port (ssh_server, 22, &ssh->server, &ssh->port);
		if (ssh->server[0] == '\0')
		{
			g_free(ssh->server);
			remmina_public_get_server_port (server, 0, &ssh->server, NULL);
		}
	}
	else if (server == NULL)
	{
		ssh->server = g_strdup ("localhost");
		ssh->port = 22;
	}
	else
	{
		remmina_public_get_server_port (server, 0, &ssh->server, NULL);
		ssh->port = 22;
	}

	ssh->user = g_strdup (ssh_username ? ssh_username : g_get_user_name ());
	ssh->password = NULL;
	ssh->auth = remmina_file_get_int (remminafile, "ssh_auth", 0);
	ssh->charset = g_strdup (remmina_file_get_string (remminafile, "ssh_charset"));

	/* Public/Private keys */
	s = (ssh_privatekey ? g_strdup (ssh_privatekey) : remmina_ssh_find_identity ());
	if (s)
	{
		ssh->privkeyfile = remmina_ssh_identity_path (s);
		g_free(s);
	}
	else
	{
		ssh->privkeyfile = NULL;
	}

	return TRUE;
}
Ejemplo n.º 2
0
const gchar*
remmina_file_get_icon_name(RemminaFile *remminafile)
{
	RemminaProtocolPlugin *plugin;

	plugin = (RemminaProtocolPlugin *) remmina_plugin_manager_get_plugin(REMMINA_PLUGIN_TYPE_PROTOCOL,
			remmina_file_get_string(remminafile, "protocol"));
	if (!plugin)
		return "remmina";

	return (remmina_file_get_int(remminafile, "ssh_enabled", FALSE) ? plugin->icon_name_ssh : plugin->icon_name);
}
Ejemplo n.º 3
0
void remmina_ftp_client_load_state(RemminaFTPClient *client, RemminaFile *remminafile)
{
	gint pos;
	GtkAllocation a;

	pos = remmina_file_get_int(remminafile, "ftp_vpanedpos", 0);
	if (pos)
	{
		gtk_widget_get_allocation(client->priv->vpaned, &a);
		if (a.height > 0 && pos > a.height - 60)
		{
			pos = a.height - 60;
		}
		gtk_paned_set_position(GTK_PANED(client->priv->vpaned), pos);
	}
}
Ejemplo n.º 4
0
static void remmina_file_editor_create_ssh_tab(RemminaFileEditor* gfe, RemminaProtocolSSHSetting ssh_setting)
{
#ifdef HAVE_LIBSSH
	RemminaFileEditorPriv* priv = gfe->priv;
	GtkWidget* table;
	GtkWidget* hbox;
	GtkWidget* widget;
	const gchar* cs;
	gchar* s;
	gint row = 0;

	if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_NONE) return;

	/* The SSH tab (implementation) */
	if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SSH ||
			ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SFTP)
	{
		s = remmina_public_combo_get_active_text (GTK_COMBO_BOX (priv->protocol_combo));
		table = remmina_file_editor_create_notebook_tab (gfe, GTK_STOCK_DIALOG_AUTHENTICATION,
				(s ? s : "SSH"), 8, 3);
		g_free(s);
	}
	else
	{
		table = remmina_file_editor_create_notebook_tab (gfe, GTK_STOCK_DIALOG_AUTHENTICATION,
				"SSH", 9, 3);

		hbox = gtk_hbox_new (TRUE, 0);
		gtk_widget_show(hbox);
		gtk_table_attach_defaults (GTK_TABLE(table), hbox, 0, 3, 0, 1);
		row++;

		widget = gtk_check_button_new_with_label (_("Enable SSH tunnel"));
		gtk_widget_show(widget);
		gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
		g_signal_connect(G_OBJECT(widget), "toggled",
				G_CALLBACK(remmina_file_editor_ssh_enabled_check_on_toggled), gfe);
		priv->ssh_enabled_check = widget;

		widget = gtk_check_button_new_with_label (_("Tunnel via loopback address"));
		gtk_widget_show(widget);
		gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
		priv->ssh_loopback_check = widget;
	}

	/* SSH Server group */
	remmina_public_create_group (GTK_TABLE(table), _("SSH Server"), row, 3, 3);
	row++;

	switch (ssh_setting)
	{
		case REMMINA_PROTOCOL_SSH_SETTING_TUNNEL:
		s = g_strdup_printf(_("Same server at port %i"), DEFAULT_SSH_PORT);
		widget = gtk_radio_button_new_with_label (NULL, s);
		g_free(s);
		gtk_widget_show(widget);
		gtk_table_attach_defaults (GTK_TABLE(table), widget, 1, 3, row, row + 1);
		priv->ssh_server_default_radio = widget;
		row++;

		widget = gtk_radio_button_new_with_label_from_widget (
				GTK_RADIO_BUTTON(priv->ssh_server_default_radio), _("Custom"));
		gtk_widget_show(widget);
		gtk_table_attach (GTK_TABLE(table), widget, 1, 2, row, row + 1, GTK_FILL, 0, 0, 0);
		g_signal_connect(G_OBJECT(widget), "toggled",
				G_CALLBACK(remmina_file_editor_ssh_server_custom_radio_on_toggled), gfe);
		priv->ssh_server_custom_radio = widget;

		widget = gtk_entry_new ();
		gtk_widget_show(widget);
		gtk_entry_set_max_length (GTK_ENTRY(widget), 100);
		gtk_widget_set_tooltip_markup (widget, _(server_tips2));
		gtk_table_attach_defaults (GTK_TABLE(table), widget, 2, 3, row, row + 1);
		priv->ssh_server_entry = widget;
		row++;
		break;

		case REMMINA_PROTOCOL_SSH_SETTING_REVERSE_TUNNEL:
		priv->ssh_server_default_radio = NULL;
		priv->ssh_server_custom_radio = NULL;

		priv->ssh_server_entry = remmina_file_editor_create_text (gfe, table, row, 1,
				_("Server"), NULL);
		gtk_widget_set_tooltip_markup (priv->ssh_server_entry, _(server_tips));
		row++;
		break;

		case REMMINA_PROTOCOL_SSH_SETTING_SSH:
		case REMMINA_PROTOCOL_SSH_SETTING_SFTP:
		priv->ssh_server_default_radio = NULL;
		priv->ssh_server_custom_radio = NULL;
		priv->ssh_server_entry = NULL;

		s = remmina_pref_get_recent ("SFTP");
		priv->server_combo = remmina_file_editor_create_combo (gfe, table, row, 1,
				_("Server"), s, remmina_file_get_string (priv->remmina_file, "server"));
		gtk_widget_set_tooltip_markup (priv->server_combo, _(server_tips));
		gtk_entry_set_activates_default (GTK_ENTRY(gtk_bin_get_child (GTK_BIN (priv->server_combo))), TRUE);
		g_free(s);
		row++;
		break;

		default:
		break;
	}

	priv->ssh_charset_combo = remmina_file_editor_create_combo (gfe, table, row, 1,
			_("Character set"), charset_list, remmina_file_get_string (priv->remmina_file, "ssh_charset"));
	row++;

	if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SSH)
	{
		widget = remmina_file_editor_create_text (gfe, table, row, 1,
				_("Startup program"), NULL);
		cs = remmina_file_get_string (priv->remmina_file, "exec");
		gtk_entry_set_text(GTK_ENTRY(widget), cs ? cs : "");
		g_hash_table_insert(priv->setting_widgets, "exec", widget);
		row++;
	}
	else if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SFTP)
	{
		widget = remmina_file_editor_create_text (gfe, table, row, 1,
				_("Startup path"), NULL);
		cs = remmina_file_get_string (priv->remmina_file, "execpath");
		gtk_entry_set_text(GTK_ENTRY(widget), cs ? cs : "");
		g_hash_table_insert(priv->setting_widgets, "execpath", widget);
		row++;
	}

	/* SSH Authentication frame */
	remmina_public_create_group (GTK_TABLE(table), _("SSH Authentication"), row, 5, 3);
	row++;

	priv->ssh_username_entry = remmina_file_editor_create_text (gfe, table, row, 1,
			_("User name"), NULL);
	row++;

	widget = gtk_radio_button_new_with_label (NULL, _("Password"));
	gtk_widget_show(widget);
	gtk_table_attach_defaults (GTK_TABLE(table), widget, 1, 3, row, row + 1);
	priv->ssh_auth_password_radio = widget;
	row++;

	widget = gtk_radio_button_new_with_label_from_widget (
			GTK_RADIO_BUTTON(priv->ssh_auth_password_radio), _("Public key (automatic)"));
	gtk_widget_show(widget);
	gtk_table_attach_defaults (GTK_TABLE(table), widget, 1, 3, row, row + 1);
	priv->ssh_auth_auto_publickey_radio = widget;
	row++;

	remmina_file_editor_create_ssh_privatekey (gfe, table, row, 1);
	row++;

	/* Set the values */
	cs = remmina_file_get_string (priv->remmina_file, "ssh_server");
	if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_TUNNEL)
	{
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->ssh_enabled_check),
				remmina_file_get_int (priv->remmina_file, "ssh_enabled", FALSE));
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->ssh_loopback_check),
				remmina_file_get_int (priv->remmina_file, "ssh_loopback", FALSE));

		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(cs ?
						priv->ssh_server_custom_radio : priv->ssh_server_default_radio), TRUE);
		gtk_entry_set_text(GTK_ENTRY(priv->ssh_server_entry),
				cs ? cs : "");
	}
	else if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_REVERSE_TUNNEL)
	{
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->ssh_enabled_check),
				remmina_file_get_int (priv->remmina_file, "ssh_enabled", FALSE));
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->ssh_loopback_check),
				remmina_file_get_int (priv->remmina_file, "ssh_loopback", FALSE));
		gtk_entry_set_text(GTK_ENTRY(priv->ssh_server_entry),
				cs ? cs : "");
	}

	cs = remmina_file_get_string (priv->remmina_file, "ssh_username");
	gtk_entry_set_text(GTK_ENTRY(priv->ssh_username_entry), cs ? cs : "");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(
					remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_PUBLICKEY ?
					priv->ssh_auth_publickey_radio :
					remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_AUTO_PUBLICKEY ?
					priv->ssh_auth_auto_publickey_radio :
					priv->ssh_auth_password_radio), TRUE);

	remmina_file_editor_ssh_enabled_check_on_toggled (NULL, gfe);
#endif
}
Ejemplo n.º 5
0
static void remmina_file_editor_create_settings(RemminaFileEditor* gfe, GtkWidget* table,
		const RemminaProtocolSetting* settings)
{
	RemminaFileEditorPriv* priv = gfe->priv;
	GtkWidget* hbox = NULL;
	GtkWidget* widget;
	gint row = 0;
	gchar** strarr;

	while (settings->type != REMMINA_PROTOCOL_SETTING_TYPE_END)
	{
		if (settings->compact)
		{
			if (hbox == NULL)
			{
				hbox = gtk_hbox_new(TRUE, 0);
				gtk_widget_show(hbox);
				gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 2, row, row + 1);
			}
		}
		switch (settings->type)
		{
			case REMMINA_PROTOCOL_SETTING_TYPE_SERVER:
				remmina_file_editor_create_server(gfe, settings, table, row);
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD:
				remmina_file_editor_create_password(gfe, table, row);
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_RESOLUTION:
				remmina_file_editor_create_resolution(gfe, settings, table, row);
				row++;
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_KEYMAP:
				strarr = remmina_pref_keymap_groups();
				priv->keymap_combo = remmina_file_editor_create_select(gfe, table, row, 0,
						_("Keyboard mapping"), (const gpointer*) strarr,
						remmina_file_get_string(priv->remmina_file, "keymap"));
				g_strfreev(strarr);
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_SCALE:
				widget = gtk_label_new(_("Horizontal scale"));
				gtk_widget_show(widget);
				gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
				gtk_table_attach(GTK_TABLE(table), widget, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);

				widget = gtk_label_new(_("Vertical scale"));
				gtk_widget_show(widget);
				gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
				gtk_table_attach(GTK_TABLE(table), widget, 0, 1, row + 1, row + 2, GTK_FILL, 0, 0, 0);

				widget = remmina_scaler_new();
				gtk_widget_show(widget);
				gtk_table_attach_defaults(GTK_TABLE(table), widget, 1, 2, row, row + 2);
				remmina_scaler_set(REMMINA_SCALER(widget),
						remmina_file_get_int(priv->remmina_file, "hscale", 0),
						remmina_file_get_int(priv->remmina_file, "vscale", 0),
						remmina_file_get_int(priv->remmina_file, "aspectscale", FALSE));
				priv->scaler_widget = widget;

				row++;
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_TEXT:
				widget = remmina_file_editor_create_text(gfe, table, row, 0,
						g_dgettext(priv->plugin->domain, settings->label),
						remmina_file_get_string(priv->remmina_file, settings->name));
				g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget);
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_SELECT:
				widget = remmina_file_editor_create_select(gfe, table, row, 0,
						g_dgettext(priv->plugin->domain, settings->label),
						(const gpointer*) settings->opt1,
						remmina_file_get_string(priv->remmina_file, settings->name));
				g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget);
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_COMBO:
				widget = remmina_file_editor_create_combo(gfe, table, row, 0,
						g_dgettext(priv->plugin->domain, settings->label),
						(const gchar*) settings->opt1,
						remmina_file_get_string(priv->remmina_file, settings->name));
				g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget);
				break;

			case REMMINA_PROTOCOL_SETTING_TYPE_CHECK:
				widget = remmina_file_editor_create_check(gfe, (hbox ? hbox : table), (hbox ? -1 : row), 0,
				g_dgettext (priv->plugin->domain, settings->label),
				remmina_file_get_int (priv->remmina_file, (gchar*) settings->name, FALSE));
				g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget);
				break;

				case REMMINA_PROTOCOL_SETTING_TYPE_FILE:
				widget = remmina_file_editor_create_chooser (gfe, table, row, 0,
						g_dgettext (priv->plugin->domain, settings->label),
						remmina_file_get_string (priv->remmina_file, settings->name),
						GTK_FILE_CHOOSER_ACTION_OPEN);
				g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget);
				break;

				case REMMINA_PROTOCOL_SETTING_TYPE_FOLDER:
				widget = remmina_file_editor_create_chooser (gfe, table, row, 0,
						g_dgettext (priv->plugin->domain, settings->label),
						remmina_file_get_string (priv->remmina_file, settings->name),
						GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
				g_hash_table_insert(priv->setting_widgets, (gchar*) settings->name, widget);
				break;

				default:
				break;
			}

		if (!settings->compact)
		{
			hbox = NULL;
			row++;
		}

		settings++;
	}

	gtk_table_resize(GTK_TABLE(table), row, 2);
}