Skip to content

Commit

Permalink
Implementing auto-fallback to Windows username. (#415)
Browse files Browse the repository at this point in the history
* Implementing auto-fallback to Windows username.

* mosh.exe recompiled.

* Minor change, as required by Menno.
  • Loading branch information
peske authored and felixse committed Jun 25, 2019
1 parent 04ed5d8 commit 45338d0
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public ApplicationSettings GetDefaultApplicationSettings()
ShowNewOutputIndicator = false,
EnableTrayIcon = true,
ShowCustomTitleInTitlebar = true,
UseMoshByDefault = true
UseMoshByDefault = true,
AutoFallbackToWindowsUsernameInLinks = true
};
}

Expand Down
15 changes: 15 additions & 0 deletions FluentTerminal.App.ViewModels/Settings/GeneralPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ public bool UseMoshByDefault
}
}

public bool AutoFallbackToWindowsUsernameInLinks
{
get => _applicationSettings.AutoFallbackToWindowsUsernameInLinks;
set
{
if (_applicationSettings.AutoFallbackToWindowsUsernameInLinks != value)
{
_applicationSettings.AutoFallbackToWindowsUsernameInLinks = value;
_settingsService.SaveApplicationSettings(_applicationSettings);
RaisePropertyChanged();
}
}
}

public bool BottomIsSelected
{
get => TabsPosition == TabsPosition.Bottom;
Expand Down Expand Up @@ -305,6 +319,7 @@ private async Task RestoreDefaults()
EnableTrayIcon = defaults.EnableTrayIcon;
ShowCustomTitleInTitlebar = defaults.ShowCustomTitleInTitlebar;
UseMoshByDefault = defaults.UseMoshByDefault;
AutoFallbackToWindowsUsernameInLinks = defaults.AutoFallbackToWindowsUsernameInLinks;
}
}

Expand Down
6 changes: 4 additions & 2 deletions FluentTerminal.App.ViewModels/SshProfileViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ private void InitializeViewModelPropertiesPrivate(SshProfile sshProfile)
{
_trayProcessCommunicationService.GetUserName().ContinueWith(t =>
{
if (string.IsNullOrEmpty(Username))
var username = t.Result;
if (string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(username))
{
Username = t.Result;
ApplicationView.RunOnDispatcherThread(() => Username = username);
}
}, TaskContinuationOptions.OnlyOnRanToCompletion);
}
Expand Down
6 changes: 6 additions & 0 deletions FluentTerminal.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ protected override async void OnActivated(IActivatedEventArgs args)
return;
}

if (_applicationSettings.AutoFallbackToWindowsUsernameInLinks &&
string.IsNullOrEmpty(connectionInfo.Username))
{
connectionInfo.Username = await _trayProcessCommunicationService.GetUserName();
}

SshConnectionInfoValidationResult result = connectionInfo.Validate();

if (result == SshConnectionInfoValidationResult.Valid)
Expand Down
Binary file modified FluentTerminal.App/MoshExecutables/x64/mosh.exe
Binary file not shown.
Binary file modified FluentTerminal.App/MoshExecutables/x86/mosh.exe
Binary file not shown.
6 changes: 6 additions & 0 deletions FluentTerminal.App/Views/SettingsPages/GeneralSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@
Margin="{StaticResource ItemMargin}"
Header="Default to Mosh for SSH connections"
IsOn="{x:Bind ViewModel.UseMoshByDefault, Mode=TwoWay}" />

<ToggleSwitch
x:Uid="AutoFallbackToWindowsUsername"
Margin="{StaticResource ItemMargin}"
Header="Use Windows username when opening SSH URLs that don't specify one"
IsOn="{x:Bind ViewModel.AutoFallbackToWindowsUsernameInLinks, Mode=TwoWay}" />
</StackPanel>
</ScrollViewer>
</Grid>
Expand Down
1 change: 1 addition & 0 deletions FluentTerminal.Models/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public class ApplicationSettings
public bool EnableTrayIcon { get; set; }
public bool ShowCustomTitleInTitlebar { get; set; }
public bool UseMoshByDefault { get; set; }
public bool AutoFallbackToWindowsUsernameInLinks { get; set; }
}
}

0 comments on commit 45338d0

Please sign in to comment.