1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-76] Added Z-Push server version check for custom sync time frame

This commit is contained in:
Patrick Simpson 2018-05-09 11:11:26 +03:00
parent e40950f836
commit b2c4c5d71b
6 changed files with 174 additions and 57 deletions

View File

@ -470,6 +470,7 @@
<Compile Include="ZPush\ZPushFolder.cs" />
<Compile Include="ZPush\ZPushSync.cs" />
<Compile Include="ZPush\ZPushTypes.cs" />
<Compile Include="ZPush\ZPushVersion.cs" />
<Compile Include="ZPush\ZPushWatcher.cs" />
<Compile Include="Features\DebugSupport\DebugDialog.cs">
<SubType>Form</SubType>

View File

@ -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<bool>
{

View File

@ -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;

View File

@ -139,13 +139,10 @@
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="_buttons.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 344</value>
</data>
<data name="_buttons.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>3, 541</value>
</data>
<data name="_buttons.Size" type="System.Drawing.Size, System.Drawing">
<value>333, 35</value>
<value>500, 42</value>
</data>
<data name="_buttons.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -181,10 +178,13 @@
<value>NoControl</value>
</data>
<data name="_labelRemaining.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 59</value>
<value>4, 88</value>
</data>
<data name="_labelRemaining.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="_labelRemaining.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 25</value>
<value>114, 40</value>
</data>
<data name="_labelRemaining.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -214,10 +214,13 @@
<value>Fill</value>
</data>
<data name="_labelAccount.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 0</value>
<value>4, 0</value>
</data>
<data name="_labelAccount.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="_labelAccount.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 27</value>
<value>114, 38</value>
</data>
<data name="_labelAccount.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -250,10 +253,13 @@
<value>All Z-Push accounts</value>
</data>
<data name="comboAccounts.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 3</value>
<value>126, 5</value>
</data>
<data name="comboAccounts.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="comboAccounts.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 21</value>
<value>368, 28</value>
</data>
<data name="comboAccounts.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -277,10 +283,13 @@
<value>Fill</value>
</data>
<data name="_labelProgress.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 27</value>
<value>4, 38</value>
</data>
<data name="_labelProgress.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="_labelProgress.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 32</value>
<value>114, 50</value>
</data>
<data name="_labelProgress.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -307,10 +316,13 @@
<value>Fill</value>
</data>
<data name="progress.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 30</value>
<value>126, 43</value>
</data>
<data name="progress.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="progress.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 26</value>
<value>368, 40</value>
</data>
<data name="progress.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -334,16 +346,16 @@
<value>Fill</value>
</data>
<data name="textRemaining.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 62</value>
<value>126, 93</value>
</data>
<data name="textRemaining.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
<value>4, 5, 4, 5</value>
</data>
<data name="textRemaining.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
<value>4, 5, 4, 5</value>
</data>
<data name="textRemaining.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 19</value>
<value>368, 30</value>
</data>
<data name="textRemaining.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -367,10 +379,13 @@
<value>Fill</value>
</data>
<data name="_labelTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 84</value>
<value>4, 128</value>
</data>
<data name="_labelTimeFrame.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="_labelTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 28</value>
<value>114, 43</value>
</data>
<data name="_labelTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
@ -430,10 +445,13 @@
<value>6 months</value>
</data>
<data name="comboTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>4, 5</value>
</data>
<data name="comboTimeFrame.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="comboTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>102, 21</value>
<value>160, 28</value>
</data>
<data name="comboTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -451,13 +469,13 @@
<value>0</value>
</data>
<data name="buttonApplyTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>181, 2</value>
<value>276, 3</value>
</data>
<data name="buttonApplyTimeFrame.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 3</value>
<value>4, 3, 4, 5</value>
</data>
<data name="buttonApplyTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>64, 23</value>
<value>96, 35</value>
</data>
<data name="buttonApplyTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -478,13 +496,13 @@
<value>1</value>
</data>
<data name="buttonResetTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>111, 2</value>
<value>172, 3</value>
</data>
<data name="buttonResetTimeFrame.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 3</value>
<value>4, 3, 4, 5</value>
</data>
<data name="buttonResetTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>64, 23</value>
<value>96, 35</value>
</data>
<data name="buttonResetTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -508,7 +526,7 @@
<value>Fill</value>
</data>
<data name="_layoutTimeFrameButtons.Location" type="System.Drawing.Point, System.Drawing">
<value>83, 84</value>
<value>122, 128</value>
</data>
<data name="_layoutTimeFrameButtons.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
@ -517,7 +535,7 @@
<value>1</value>
</data>
<data name="_layoutTimeFrameButtons.Size" type="System.Drawing.Size, System.Drawing">
<value>248, 28</value>
<value>376, 43</value>
</data>
<data name="_layoutTimeFrameButtons.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -544,10 +562,13 @@
<value>Fill</value>
</data>
<data name="_labelResync.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 132</value>
<value>4, 202</value>
</data>
<data name="_labelResync.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="_labelResync.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 35</value>
<value>114, 50</value>
</data>
<data name="_labelResync.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -586,13 +607,16 @@
<value>NoControl</value>
</data>
<data name="buttonGAB.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 135</value>
<value>126, 207</value>
</data>
<data name="buttonGAB.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="buttonGAB.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
<value>4, 5, 4, 5</value>
</data>
<data name="buttonGAB.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 29</value>
<value>368, 40</value>
</data>
<data name="buttonGAB.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -628,13 +652,16 @@
<value>NoControl</value>
</data>
<data name="buttonSignatures.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 170</value>
<value>126, 257</value>
</data>
<data name="buttonSignatures.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="buttonSignatures.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
<value>4, 5, 4, 5</value>
</data>
<data name="buttonSignatures.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 29</value>
<value>368, 40</value>
</data>
<data name="buttonSignatures.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -670,13 +697,16 @@
<value>NoControl</value>
</data>
<data name="buttonServerData.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 205</value>
<value>126, 307</value>
</data>
<data name="buttonServerData.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="buttonServerData.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
<value>4, 5, 4, 5</value>
</data>
<data name="buttonServerData.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 29</value>
<value>368, 40</value>
</data>
<data name="buttonServerData.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -712,13 +742,16 @@
<value>NoControl</value>
</data>
<data name="buttonFullResync.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 240</value>
<value>126, 357</value>
</data>
<data name="buttonFullResync.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="buttonFullResync.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
<value>4, 5, 4, 5</value>
</data>
<data name="buttonFullResync.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 29</value>
<value>368, 40</value>
</data>
<data name="buttonFullResync.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
@ -742,13 +775,16 @@
<value>Fill</value>
</data>
<data name="_labelResyncOption.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 272</value>
<value>126, 402</value>
</data>
<data name="_labelResyncOption.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="_labelResyncOption.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 6, 0, 0</value>
<value>0, 9, 0, 0</value>
</data>
<data name="_labelResyncOption.Size" type="System.Drawing.Size, System.Drawing">
<value>242, 64</value>
<value>368, 126</value>
</data>
<data name="_labelResyncOption.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -769,13 +805,16 @@
<value>Fill</value>
</data>
<data name="_layoutMain.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>4, 5</value>
</data>
<data name="_layoutMain.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="_layoutMain.RowCount" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="_layoutMain.Size" type="System.Drawing.Size, System.Drawing">
<value>331, 336</value>
<value>498, 528</value>
</data>
<data name="_layoutMain.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -793,7 +832,7 @@
<value>1</value>
</data>
<data name="_layoutMain.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="_labelRemaining" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_labelAccount" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="comboAccounts" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelProgress" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="progress" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="textRemaining" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelTimeFrame" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_layoutTimeFrameButtons" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelResync" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="buttonGAB" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonSignatures" Row="7" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonServerData" Row="8" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonFullResync" Row="9" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelResyncOption" Row="10" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="_labelRemaining" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_labelAccount" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="comboAccounts" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelProgress" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="progress" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="textRemaining" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelTimeFrame" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_layoutTimeFrameButtons" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelResync" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="buttonGAB" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonSignatures" Row="7" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonServerData" Row="8" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonFullResync" Row="9" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelResyncOption" Row="10" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,31,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="_layout.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
@ -801,11 +840,14 @@
<data name="_layout.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="_layout.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="_layout.RowCount" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="_layout.Size" type="System.Drawing.Size, System.Drawing">
<value>337, 381</value>
<value>506, 586</value>
</data>
<data name="_layout.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -829,13 +871,16 @@
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
<value>9, 20</value>
</data>
<data name="$this.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>337, 381</value>
<value>506, 586</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>

View File

@ -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);

View File

@ -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);
}
}
}