Skip to content

Commit

Permalink
Merge branch 'release/1.0.15'
Browse files Browse the repository at this point in the history
  • Loading branch information
canton7 committed Apr 20, 2015
2 parents ff8c56f + ac2998c commit bc43007
Show file tree
Hide file tree
Showing 41 changed files with 919 additions and 184 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

v1.0.15
-------

- Fix crash on startup if Syncthing is slow to start (#55)
- Remember window size-position (#51)
- Zoom built-in borwser (#52)
- Add support for aribtrary environmental variables for Syncthing

v1.0.14
-------

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace :portable do
Dir.chdir(arch_config.bin_dir) do
files = FileList['**/*'].exclude(
'*.xml', '*.vshost.*', '*.log', '*.Installer.config', '*/FluentValidation.resources.dll',
'*System.Windows.Interactivity.resources.dll', 'syncthing.exe', 'data')
'*/System.Windows.Interactivity.resources.dll', 'syncthing.exe', 'data')

files.each do |file|
cp_to_portable(portable_dir, file)
Expand Down
18 changes: 15 additions & 3 deletions server/version_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,23 @@ function get_with_wildcard($src, $value, $default = null)
}

$versions = [
'1.0.15' => [
'installed' => [
'direct_download_url' => [
'x64' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.0.15/SyncTrayzorSetup-x64.exe',
'x86' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.0.15/SyncTrayzorSetup-x86.exe',
],
],
'release_page_url' => 'https://github.com/canton7/SyncTrayzor/releases/tag/v1.0.15',
'release_notes' => "- Fix crash on startup if Syncthing is slow to start (#55)\n- Remember window size-position (#51)\n- Zoom built-in borwser (#52)\n- Add support for aribtrary environmental variables for Syncthing\n",
],
'1.0.14' => [
'installed' => [
'direct_download_url' => []
],
'release_page_url' => 'https://github.com/canton7/SyncTrayzor/releases/tag/v1.0.14',
'release_notes' => "- Give Syncthing more than 10 seconds to start, fixing crash (#47, #48, #50)\n- Better Syncthing API management in general\n- Add support for 150% and 200% DPI to tray icon\n- Slightly improve UI\n",
],

'1.0.13' => [
'installed' => [
'direct_download_url' => []
Expand All @@ -83,8 +92,9 @@ function get_with_wildcard($src, $value, $default = null)
];

$upgrades = [
'1.0.13' => ['to' => '1.0.14', 'formatter' => '2'],
'1.0.12' => ['to' => '1.0.14', 'formatter' => '1'],
'1.0.14' => ['to' => 'latest', 'formatter' => '2'],
'1.0.13' => ['to' => 'latest', 'formatter' => '1'],
'1.0.12' => ['to' => 'latest', 'formatter' => '1'],
];

$response_formatters = [
Expand Down Expand Up @@ -134,6 +144,8 @@ function get_with_wildcard($src, $value, $default = null)
else if (isset($upgrades[$version]))
{
$to_version = $upgrades[$version]['to'];
if ($to_version == 'latest')
$to_version = array_keys($versions)[0];
$formatter = $response_formatters[$upgrades[$version]['formatter']];
$overrides = isset($upgrades[$version]['overrides']) ? $upgrades[$version]['overrides'] : [];
$to_version_info = $versions[$to_version];
Expand Down
4 changes: 2 additions & 2 deletions src/ProcessRunner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.14.0")]
[assembly: AssemblyFileVersion("1.0.14.0")]
[assembly: AssemblyVersion("1.0.15.0")]
[assembly: AssemblyFileVersion("1.0.15.0")]
1 change: 1 addition & 0 deletions src/SyncTrayzor/App.Installer.config.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<xsl:template match="/configuration/applicationSettings//setting[@name='PathConfiguration']//SyncthingCustomHomePath/text()">%LOCALAPPDATA%\SyncTrayzor\syncthing</xsl:template>
<xsl:template match="/configuration/applicationSettings//setting[@name='PathConfiguration']//SyncthingPath/text()">%APPDATA%\SyncTrayzor\syncthing.exe</xsl:template>
<xsl:template match="/configuration/applicationSettings//setting[@name='PathConfiguration']//ConfigurationFilePath/text()">%APPDATA%\SyncTrayzor\config.xml</xsl:template>
<xsl:template match="/configuration/applicationSettings//setting[@name='PathConfiguration']//ConfigurationFileBackupPath/text()">%APPDATA%\SyncTrayzor\config-backups</xsl:template>

<xsl:template match="/configuration/applicationSettings//setting[@name='DefaultUserConfiguration']//SyncthingUseCustomHome/text()">false</xsl:template>

Expand Down
13 changes: 8 additions & 5 deletions src/SyncTrayzor/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@
<setting name="UpdateCheckIntervalSeconds" serializeAs="String">
<value>10800</value>
</setting>
<setting name="SyncthingConnectTimeoutSeconds" serializeAs="String">
<value>600</value>
</setting>
<setting name="DefaultUserConfiguration" serializeAs="Xml">
<value>
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="2">
<ShowTrayIconOnlyOnClose>false</ShowTrayIconOnlyOnClose>
<MinimizeToTray>false</MinimizeToTray>
<CloseToTray>true</CloseToTray>
<ShowSynchronizedBalloon>true</ShowSynchronizedBalloon>
<ShowDeviceConnectivityBalloons>true</ShowDeviceConnectivityBalloons>
<SyncthingAddress>localhost:8384</SyncthingAddress>
<StartSyncthingAutomatically>true</StartSyncthingAutomatically>
<SyncthingEnvironmentalVariables />
<SyncthingUseCustomHome>true</SyncthingUseCustomHome>
<SyncthingDenyUpgrade>false</SyncthingDenyUpgrade>
<SyncthingRunLowPriority>false</SyncthingRunLowPriority>
Expand All @@ -59,23 +63,22 @@
<ObfuscateDeviceIDs>true</ObfuscateDeviceIDs>
<UseComputerCulture>true</UseComputerCulture>
<ShowSyncthingConsole>true</ShowSyncthingConsole>
<SyncthingWebBrowserZoomLevel>0</SyncthingWebBrowserZoomLevel>
</Configuration>
</value>
</setting>
<setting name="PathConfiguration" serializeAs="Xml">
<value>
<PathConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<LogFilePath>%EXEPATH%\data\logs</LogFilePath>
<LogFilePath>%EXEPATH%\logs</LogFilePath>
<SyncthingCustomHomePath>%EXEPATH%\data\syncthing</SyncthingCustomHomePath>
<SyncthingPath>%EXEPATH%\syncthing.exe</SyncthingPath>
<ConfigurationFilePath>%EXEPATH%\data\config.xml</ConfigurationFilePath>
<ConfigurationFileBackupPath>%EXEPATH%\data\config-backups</ConfigurationFileBackupPath>
</PathConfiguration>
</value>
</setting>
<setting name="SyncthingConnectTimeoutSeconds" serializeAs="String">
<value>600</value>
</setting>
</SyncTrayzor.Properties.Settings>
</applicationSettings>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Expand Down
3 changes: 2 additions & 1 deletion src/SyncTrayzor/NotifyIcon/NotifyIconViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public NotifyIconViewModel(
this.syncThingManager.DataLoaded += (o, e) =>
{
this.Folders = new BindableCollection<FolderViewModel>(this.syncThingManager.FetchAllFolders()
.Select(x => new FolderViewModel(x, this.processStartProvider)));
.Select(x => new FolderViewModel(x, this.processStartProvider))
.OrderBy(x => x.FolderId));
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/SyncTrayzor/Pages/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@
<CheckBox DockPanel.Dock="Top" IsChecked="{Binding SyncthingDenyUpgrade}"
Content="{l:Loc SettingsView_SyncthingDenyUpgrade}"
ToolTip="{l:Loc SettingsView_SyncthingDenyUpgrade_ToolTip}"/>
<Label DockPanel.Dock="Top" Target="{Binding ElementName=TraceVariables}" Content="{l:Loc SettingsView_TraceVariables}"/>
<TextBox DockPanel.Dock="Top" x:Name="TraceVariables" Text="{Binding TraceVariables, UpdateSourceTrigger=PropertyChanged}"/>
<Label DockPanel.Dock="Top" Target="{Binding ElementName=SyncThingEnvironmentalVariables}" Content="{l:Loc SettingsView_SyncthingEnvironmentalVariables}"/>
<TextBox DockPanel.Dock="Top" x:Name="SyncThingEnvironmentalVariables" Text="{Binding SyncThingEnvironmentalVariables, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,40,20"/>
</DockPanel>
</GroupBox>
</Expander>
Expand Down
61 changes: 58 additions & 3 deletions src/SyncTrayzor/Pages/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace SyncTrayzor.Pages
Expand All @@ -18,6 +19,50 @@ public class WatchedFolder
public bool IsSelected { get; set; }
}

public static class EnvironmentalVariablesParser
{
public static string Format(EnvironmentalVariableCollection result)
{
return String.Join(" ", result.Select(x => String.Format("{0}={1}", x.Key, x.Value.Contains(' ') ? "\"" + x.Value + "\"" : x.Value)));
}

public static bool TryParse(string input, out EnvironmentalVariableCollection result)
{
if (String.IsNullOrWhiteSpace(input))
{
result = new EnvironmentalVariableCollection();
return true;
}

result = null;

// http://stackoverflow.com/a/4780801/1086121
var parts = Regex.Split(input.Trim(), "(?<=^[^\"]+(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");

var finalResult = new EnvironmentalVariableCollection();
foreach (var part in parts)
{
var subParts = part.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
if (subParts.Length != 2)
return false;

if (subParts[0].Contains('"'))
return false;

if (subParts[1].StartsWith("\"") != subParts[1].EndsWith("\""))
return false;

if (finalResult.ContainsKey(subParts[0]))
return false;

finalResult.Add(subParts[0], subParts[1].Trim('"'));
}

result = finalResult;
return true;
}
}

public class SettingsViewModelValidator : AbstractValidator<SettingsViewModel>
{
private const string apiKeyChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
Expand All @@ -37,6 +82,12 @@ public SettingsViewModelValidator()
}).WithMessage(Localizer.Translate("SettingsView_Validation_InvalidUrl"));

RuleFor(x => x.SyncThingApiKey).NotEmpty().WithMessage(Localizer.Translate("SettingsView_Validation_NotShouldBeEmpty"));

RuleFor(x => x.SyncThingEnvironmentalVariables).Must(str =>
{
EnvironmentalVariableCollection result;
return EnvironmentalVariablesParser.TryParse(str, out result);
}).WithMessage(Localizer.Translate("SettingsView_Validation_SyncthingEnvironmentalVariablesMustHaveFormat"));
}
}

Expand Down Expand Up @@ -80,7 +131,7 @@ public bool StartMinimizedEnabled
public BindableCollection<WatchedFolder> WatchedFolders { get; set; }

public bool SyncthingUseCustomHome { get; set; }
public string TraceVariables { get; set; }
public string SyncThingEnvironmentalVariables { get; set; }
public bool SyncthingDenyUpgrade { get; set; }

public SettingsViewModel(
Expand Down Expand Up @@ -124,7 +175,7 @@ public SettingsViewModel(
IsSelected = x.IsWatched
}));
this.SyncthingUseCustomHome = configuration.SyncthingUseCustomHome;
this.TraceVariables = configuration.SyncthingTraceFacilities;
this.SyncThingEnvironmentalVariables = EnvironmentalVariablesParser.Format(configuration.SyncthingEnvironmentalVariables);
this.SyncthingDenyUpgrade = configuration.SyncthingDenyUpgrade;
}

Expand Down Expand Up @@ -165,7 +216,11 @@ public void Save()

configuration.Folders = this.WatchedFolders.Select(x => new FolderConfiguration(x.Folder, x.IsSelected)).ToList();
configuration.SyncthingUseCustomHome = this.SyncthingUseCustomHome;
configuration.SyncthingTraceFacilities = String.IsNullOrWhiteSpace(this.TraceVariables) ? null : this.TraceVariables;

EnvironmentalVariableCollection envVars;
EnvironmentalVariablesParser.TryParse(this.SyncThingEnvironmentalVariables, out envVars);
configuration.SyncthingEnvironmentalVariables = envVars;

configuration.SyncthingDenyUpgrade = this.SyncthingDenyUpgrade;

this.configurationProvider.Save(configuration);
Expand Down
18 changes: 18 additions & 0 deletions src/SyncTrayzor/Pages/ShellView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
Title="SyncTrayzor">
<i:Interaction.Behaviors>
<xaml:ActivateBehaviour Activated="{Binding WindowActivated}"/>
<xaml:WindowPlacementBehaviour Placement="{Binding Placement}"/>
</i:Interaction.Behaviors>
<Window.InputBindings>
<MouseBinding Gesture="{x:Static xaml:MouseWheelGesture.CtrlUp}" Command="{s:Action BrowserZoomIn}" s:View.ActionTarget="{Binding}"/>
<MouseBinding Gesture="{x:Static xaml:MouseWheelGesture.CtrlDown}" Command="{s:Action BrowserZoomOut}" s:View.ActionTarget="{Binding}"/>
<!-- Lots of different sorts of + and - on the keyboard: gotta catch em all! -->
<KeyBinding Key="OemPlus" Modifiers="Control+Shift" Command="{s:Action BrowserZoomIn}" s:View.ActionTarget="{Binding}"/>
<KeyBinding Key="OemPlus" Modifiers="Control" Command="{s:Action BrowserZoomIn}" s:View.ActionTarget="{Binding}"/>
<KeyBinding Key="Add" Modifiers="Control" Command="{s:Action BrowserZoomIn}" s:View.ActionTarget="{Binding}"/>
<KeyBinding Key="OemMinus" Modifiers="Control" Command="{s:Action BrowserZoomOut}" s:View.ActionTarget="{Binding}"/>
<KeyBinding Key="Subtract" Modifiers="Control" Command="{s:Action BrowserZoomOut}" s:View.ActionTarget="{Binding}"/>
<KeyBinding Key="D0" Modifiers="Control" Command="{s:Action BrowserZoomReset}" s:View.ActionTarget="{Binding}"/>
<KeyBinding Key="NumPad0" Modifiers="Control" Command="{s:Action BrowserZoomReset}" s:View.ActionTarget="{Binding}"/>
</Window.InputBindings>
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="{l:Loc ShellView_Menu_File}">
Expand All @@ -27,6 +40,11 @@
</MenuItem>
<MenuItem Header="{l:Loc ShellView_Menu_View}">
<MenuItem Header="{l:Loc ShellView_Menu_View_SyncthingConsole}" IsCheckable="True" IsChecked="{Binding ShowConsole}"/>
<MenuItem Header="{l:Loc ShellView_Menu_Zoom}" IsEnabled="{Binding CanZoomBrowser}">
<MenuItem Header="{l:Loc ShellView_Menu_Zoom_In}" InputGestureText="Ctrl++" Command="{s:Action BrowserZoomIn}"/>
<MenuItem Header="{l:Loc ShellView_Menu_Zoom_Out}" InputGestureText="Ctrl+-" Command="{s:Action BrowserZoomOut}"/>
<MenuItem Header="{l:Loc ShellView_Menu_Zoom_Reset}" InputGestureText="Ctrl+0" Command="{s:Action BrowserZoomReset}"/>
</MenuItem>
</MenuItem>
<MenuItem Header="{l:Loc ShellView_Menu_Help}">
<MenuItem Header="{l:Loc ShellView_Menu_Help_About}" Command="{s:Action ShowAbout}"/>
Expand Down
35 changes: 28 additions & 7 deletions src/SyncTrayzor/Pages/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ShellViewModel : Screen

public bool WindowActivated { get; set; }
public bool ShowConsole { get; set; }
public WindowPlacement Placement { get; set; }
public ConsoleViewModel Console { get; private set; }
public ViewerViewModel Viewer { get; private set; }

Expand All @@ -53,14 +54,19 @@ public ShellViewModel(
this.aboutViewModelFactory = aboutViewModelFactory;
this.processStartProvider = processStartProvider;

var configuration = this.configurationProvider.Load();

this.Console.ConductWith(this);
this.Viewer.ConductWith(this);

this.syncThingManager.StateChanged += (o, e) => this.SyncThingState = e.NewState;
this.syncThingManager.ProcessExitedWithError += (o, e) => this.ShowExitedWithError();

this.ShowConsole = this.configurationProvider.Load().ShowSyncthingConsole;
this.Bind(s => s.ShowConsole, (o, e) => this.SetConsoleVisible(e.NewValue));
this.ShowConsole = configuration.ShowSyncthingConsole;
this.Bind(s => s.ShowConsole, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.ShowSyncthingConsole = e.NewValue));

this.Placement = configuration.WindowPlacement;
this.Bind(s => s.Placement, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.WindowPlacement = e.NewValue));
}

public bool CanStart
Expand Down Expand Up @@ -132,15 +138,30 @@ public void ShowSettings()
this.windowManager.ShowDialog(vm);
}

public void ShowAbout()
public bool CanZoomBrowser
{
var vm = this.aboutViewModelFactory();
this.windowManager.ShowDialog(vm);
get { return this.SyncThingState == SyncThingState.Running; }
}

public void BrowserZoomIn()
{
this.Viewer.ZoomIn();
}

public void SetConsoleVisible(bool visible)
public void BrowserZoomOut()
{
this.configurationProvider.AtomicLoadAndSave(configuration => configuration.ShowSyncthingConsole = visible);
this.Viewer.ZoomOut();
}

public void BrowserZoomReset()
{
this.Viewer.ZoomReset();
}

public void ShowAbout()
{
var vm = this.aboutViewModelFactory();
this.windowManager.ShowDialog(vm);
}

public void ShowExitedWithError()
Expand Down
3 changes: 2 additions & 1 deletion src/SyncTrayzor/Pages/ViewerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:l="clr-namespace:SyncTrayzor.Localization"
xmlns:xaml="clr-namespace:SyncTrayzor.Xaml"
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<cefSharp:ChromiumWebBrowser x:Name="browser" Address="{Binding Location}" WebBrowser="{Binding WebBrowser, Mode=OneWayToSource}"/>

<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{l:Loc ViewerView_SyncthingStarting}"
Visibility="{Binding ShowSyncThingStarting, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
FontSize="16"/>


<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"
Visibility="{Binding ShowSyncThingStopped, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
<TextBlock FontSize="16" HorizontalAlignment="Center" Text="{l:Loc ViewerView_SyncthingStopped}"/>
Expand Down
Loading

0 comments on commit bc43007

Please sign in to comment.