diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj index 9a3fc86..57fb0a8 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj @@ -470,6 +470,7 @@ + Form diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs index 93c69d3..5063508 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs @@ -737,6 +737,10 @@ namespace Acacia.Features.SyncState return new SyncStateImpl(this, account == null ? Watcher.Accounts.GetAccounts().ToArray() : new ZPushAccount[] { account }); } + public bool SupportsSyncTimeFrame(ZPushAccount account) + { + return account?.ZPushVersion.IsAtLeast(2, 4) == true; + } private class SetDeviceOptionsRequest : SoapRequest { diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.cs index a27609c..bccaa5e 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.cs @@ -73,7 +73,11 @@ namespace Acacia.Features.SyncState private void comboAccounts_SelectedIndexChanged(object sender, EventArgs e) { _syncState = _feature.GetSyncState(SelectedAccount); - _labelTimeFrame.Enabled = comboTimeFrame.Enabled = SelectedAccount != null; + + // Check if time frame should be visible + // It is visible if a single account is selected that supports it + bool haveSyncTimeFrame = _feature.SupportsSyncTimeFrame(SelectedAccount); + _labelTimeFrame.Visible = comboTimeFrame.Visible = buttonApplyTimeFrame.Visible = buttonResetTimeFrame.Visible = haveSyncTimeFrame; if (SelectedAccount == null) comboTimeFrame.SelectedIndex = 0; diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.resx b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.resx index 54b2bbf..d3b1824 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.resx +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/SyncStateDialog.resx @@ -139,13 +139,10 @@ - 2, 344 - - - 2, 2, 2, 2 + 3, 541 - 333, 35 + 500, 42 0 @@ -181,10 +178,13 @@ NoControl - 3, 59 + 4, 88 + + + 4, 0, 4, 0 - 77, 25 + 114, 40 5 @@ -214,10 +214,13 @@ Fill - 3, 0 + 4, 0 + + + 4, 0, 4, 0 - 77, 27 + 114, 38 0 @@ -250,10 +253,13 @@ All Z-Push accounts - 86, 3 + 126, 5 + + + 4, 5, 4, 5 - 242, 21 + 368, 28 0 @@ -277,10 +283,13 @@ Fill - 3, 27 + 4, 38 + + + 4, 0, 4, 0 - 77, 32 + 114, 50 2 @@ -307,10 +316,13 @@ Fill - 86, 30 + 126, 43 + + + 4, 5, 4, 5 - 242, 26 + 368, 40 1 @@ -334,16 +346,16 @@ Fill - 86, 62 + 126, 93 - 3, 3, 3, 3 + 4, 5, 4, 5 - 3, 3, 3, 3 + 4, 5, 4, 5 - 242, 19 + 368, 30 2 @@ -367,10 +379,13 @@ Fill - 3, 84 + 4, 128 + + + 4, 0, 4, 0 - 77, 28 + 114, 43 9 @@ -430,10 +445,13 @@ 6 months - 3, 3 + 4, 5 + + + 4, 5, 4, 5 - 102, 21 + 160, 28 0 @@ -451,13 +469,13 @@ 0 - 181, 2 + 276, 3 - 3, 2, 3, 3 + 4, 3, 4, 5 - 64, 23 + 96, 35 2 @@ -478,13 +496,13 @@ 1 - 111, 2 + 172, 3 - 3, 2, 3, 3 + 4, 3, 4, 5 - 64, 23 + 96, 35 1 @@ -508,7 +526,7 @@ Fill - 83, 84 + 122, 128 0, 0, 0, 0 @@ -517,7 +535,7 @@ 1 - 248, 28 + 376, 43 3 @@ -544,10 +562,13 @@ Fill - 3, 132 + 4, 202 + + + 4, 0, 4, 0 - 77, 35 + 114, 50 8 @@ -586,13 +607,16 @@ NoControl - 86, 135 + 126, 207 + + + 4, 5, 4, 5 - 3, 3, 3, 3 + 4, 5, 4, 5 - 242, 29 + 368, 40 4 @@ -628,13 +652,16 @@ NoControl - 86, 170 + 126, 257 + + + 4, 5, 4, 5 - 3, 3, 3, 3 + 4, 5, 4, 5 - 242, 29 + 368, 40 5 @@ -670,13 +697,16 @@ NoControl - 86, 205 + 126, 307 + + + 4, 5, 4, 5 - 3, 3, 3, 3 + 4, 5, 4, 5 - 242, 29 + 368, 40 6 @@ -712,13 +742,16 @@ NoControl - 86, 240 + 126, 357 + + + 4, 5, 4, 5 - 3, 3, 3, 3 + 4, 5, 4, 5 - 242, 29 + 368, 40 7 @@ -742,13 +775,16 @@ Fill - 86, 272 + 126, 402 + + + 4, 0, 4, 0 - 0, 6, 0, 0 + 0, 9, 0, 0 - 242, 64 + 368, 126 4 @@ -769,13 +805,16 @@ Fill - 3, 3 + 4, 5 + + + 4, 5, 4, 5 11 - 331, 336 + 498, 528 1 @@ -793,7 +832,7 @@ 1 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="_labelRemaining" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="_labelAccount" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboAccounts" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelProgress" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="progress" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="textRemaining" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelTimeFrame" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="_layoutTimeFrameButtons" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelResync" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="buttonGAB" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonSignatures" Row="7" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonServerData" Row="8" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonFullResync" Row="9" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelResyncOption" Row="10" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="_labelRemaining" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="_labelAccount" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboAccounts" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelProgress" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="progress" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="textRemaining" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelTimeFrame" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="_layoutTimeFrameButtons" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelResync" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="buttonGAB" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonSignatures" Row="7" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonServerData" Row="8" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonFullResync" Row="9" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="_labelResyncOption" Row="10" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,31,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /></TableLayoutSettings> Fill @@ -801,11 +840,14 @@ 0, 0 + + 4, 5, 4, 5 + 2 - 337, 381 + 506, 586 0 @@ -829,13 +871,16 @@ True - 6, 13 + 9, 20 True - 337, 381 + 506, 586 + + + 4, 5, 4, 5 CenterParent diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccount.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccount.cs index 4e6bc4b..f1972ae 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccount.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccount.cs @@ -121,7 +121,7 @@ namespace Acacia.ZPush private set; } - public string ZPushVersion + public ZPushVersion ZPushVersion { get; private set; @@ -144,7 +144,7 @@ namespace Acacia.ZPush Capabilities = response.Capabilities; // TODO: move these properties to the features? Though it's nice to have them here for the debug dialog GABFolder = response.GABName; - ZPushVersion = response.ZPushVersion; + ZPushVersion = ZPushVersion.FromString(response.ZPushVersion); ServerSignaturesHash = response.SignaturesHash; Confirmed = Capabilities == null ? ConfirmationType.IsNotZPush : ConfirmationType.IsZPush; Logger.Instance.Info(this, "ZPush confirmation: {0} -> {1}, {2}", Confirmed, Capabilities, GABFolder); diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushVersion.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushVersion.cs new file mode 100644 index 0000000..1d89da0 --- /dev/null +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushVersion.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Acacia.ZPush +{ + public class ZPushVersion + { + private readonly int major; + private readonly int minor; + private readonly string version; + + private ZPushVersion(int major, int minor, string version) + { + this.major = major; + this.minor = minor; + this.version = version; + } + + public override string ToString() + { + return version; + } + + public override bool Equals(object obj) + { + ZPushVersion rhs = obj as ZPushVersion; + if (rhs == null) + return false; + return version.Equals(rhs.version); + } + + public override int GetHashCode() + { + return version.GetHashCode(); + } + + public static ZPushVersion FromString(string version) + { + if (string.IsNullOrWhiteSpace(version)) + return null; + + string[] parts = version.Split('.'); + try + { + int major = int.Parse(parts[0]); + int minor = int.Parse(parts[1]); + return new ZPushVersion(major, minor, version); + } + catch (Exception) + { + return null; + } + } + + public bool IsAtLeast(int major, int minor) + { + return (this.major > major) || (this.major == major && this.minor >= minor); + } + } +}