Ap/ssh Implemented SSH by using the exsting infrastructure (#293)
* Appveyor builds (#6) * SSH implemented. * Implementing SSH by using the existing app infrastructure. * Refactored to new command instead of a profile * Update .gitignore
This commit is contained in:
1 parent
dbd8632076
commit
973b1a4963
13 files changed
+1073
-893
No files matched your search
@@ -9,6 +9,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FluentTerminal.App.Services.Implementation;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
@@ -20,6 +21,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
private readonly IKeyboardCommandService _keyboardCommandService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly ITrayProcessCommunicationService _trayProcessCommunicationService;
|
||||
private readonly IDefaultValueProvider _defaultValueProvider;
|
||||
private ApplicationSettings _applicationSettings;
|
||||
private string _background;
|
||||
private double _backgroundOpacity;
|
||||
@@ -28,7 +30,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
private string _windowTitle;
|
||||
|
||||
public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService,
|
||||
IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService)
|
||||
IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService, IDefaultValueProvider defaultValueProvider)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
_settingsService.CurrentThemeChanged += OnCurrentThemeChanged;
|
||||
@@ -42,8 +44,10 @@ namespace FluentTerminal.App.ViewModels
|
||||
ApplicationView = applicationView;
|
||||
_dispatcherTimer = dispatcherTimer;
|
||||
_clipboardService = clipboardService;
|
||||
_defaultValueProvider = defaultValueProvider;
|
||||
_keyboardCommandService = keyboardCommandService;
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.NewTab), () => AddTerminal());
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.NewRemoteTab), () => AddRemoteTerminal());
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.ConfigurableNewTab), () => AddConfigurableTerminal());
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.ChangeTabTitle), () => SelectedTerminal.EditTitle());
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.CloseTab), CloseCurrentTab);
|
||||
@@ -214,6 +218,34 @@ namespace FluentTerminal.App.ViewModels
|
||||
});
|
||||
}
|
||||
|
||||
public Task AddRemoteTerminal()
|
||||
{
|
||||
return ApplicationView.RunOnDispatcherThread(async () =>
|
||||
{
|
||||
var connectionInfo = await _dialogService.ShowSshConnectionInfoDialogAsync();
|
||||
|
||||
if (connectionInfo == null)
|
||||
{
|
||||
if (Terminals.Count == 0)
|
||||
{
|
||||
await ApplicationView.TryClose();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var profile = new ShellProfile
|
||||
{
|
||||
Arguments = $"-p {connectionInfo.Port:#####} {connectionInfo.Username}@{connectionInfo.Host}",
|
||||
Location = @"C:\Windows\System32\OpenSSH\ssh.exe",
|
||||
WorkingDirectory = string.Empty,
|
||||
LineEndingTranslation = LineEndingStyle.DoNotModify,
|
||||
};
|
||||
|
||||
AddTerminal(profile);
|
||||
});
|
||||
}
|
||||
|
||||
public void AddTerminal()
|
||||
{
|
||||
var profile = _settingsService.GetDefaultShellProfile();
|
||||
@@ -232,6 +264,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
var terminal = new TerminalViewModel(_settingsService, _trayProcessCommunicationService, _dialogService, _keyboardCommandService,
|
||||
_applicationSettings, profile, ApplicationView, _dispatcherTimer, _clipboardService);
|
||||
|
||||
terminal.Closed += OnTerminalClosed;
|
||||
terminal.ShellTitleChanged += Terminal_ShellTitleChanged;
|
||||
terminal.CustomTitleChanged += Terminal_CustomTitleChanged;
|
||||
|
||||
Reference in new issue
Block a user