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

[KOE-76] Implemented per-account sync timeframe in sync dialog

This commit is contained in:
Patrick Simpson 2018-02-28 17:00:51 +02:00
parent 126bfff3be
commit 8c08363b1f
15 changed files with 613 additions and 213 deletions

View File

@ -70,6 +70,7 @@ namespace Acacia.Controls
#endregion
#region KUITaskProgress
// TODO: if BusyHider is not set, pop up dialogs
public string BusyText
{

View File

@ -134,7 +134,7 @@ namespace Acacia.Features.Signatures
if (serverSignatureHash != null)
{
Logger.Instance.Trace(this, "Checking signature hash for account {0}: {1}", account, serverSignatureHash);
if (serverSignatureHash == account.Account.LocalSignaturesHash)
if (serverSignatureHash == account.LocalSignaturesHash)
return;
}
@ -145,7 +145,7 @@ namespace Acacia.Features.Signatures
string hash = FetchSignatures(account);
// Store updated hash
account.Account.LocalSignaturesHash = hash;
account.LocalSignaturesHash = hash;
Logger.Instance.Debug(this, "Updated signatures: {0}: {1}", account, hash);
}
catch (Exception e)
@ -206,13 +206,13 @@ namespace Acacia.Features.Signatures
}
// Set default signatures if available and none are set
if (!string.IsNullOrEmpty(result.new_message) && ShouldSetSignature(account.Account.SignatureNewMessage))
if (!string.IsNullOrEmpty(result.new_message) && ShouldSetSignature(account.SignatureNewMessage))
{
account.Account.SignatureNewMessage = fullNames[result.new_message];
account.SignatureNewMessage = fullNames[result.new_message];
}
if (!string.IsNullOrEmpty(result.replyforward_message) && ShouldSetSignature(account.Account.SignatureReplyForwardMessage))
if (!string.IsNullOrEmpty(result.replyforward_message) && ShouldSetSignature(account.SignatureReplyForwardMessage))
{
account.Account.SignatureReplyForwardMessage = fullNames[result.replyforward_message];
account.SignatureReplyForwardMessage = fullNames[result.replyforward_message];
}
return result.hash;
@ -291,7 +291,7 @@ namespace Acacia.Features.Signatures
private void GAB_SyncFinished(GABHandler gab)
{
ReplacePlaceholders(gab, gab.ActiveAccount.Account.SignatureNewMessage, gab.ActiveAccount.Account.SignatureNewMessage);
ReplacePlaceholders(gab, gab.ActiveAccount.SignatureNewMessage, gab.ActiveAccount.SignatureNewMessage);
}
private void ReplacePlaceholders(GABHandler gab, params string[] signatures)

View File

@ -1,4 +1,4 @@
/// Copyright 2017 Kopano b.v.
/// Copyright 2018 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
@ -576,10 +576,13 @@ namespace Acacia.Features.SyncState
if (_dialog != null)
return;
// Get the current account. If no Z-Push account is selected, the dialog will open for all accounts.
ZPushAccount account = Watcher.CurrentZPushAccount();
// Ramp up the checking schedule while the dialog is open
// The other check sets per-account schedules, we use the global one, so they should't interfere.
TimeSpan? old = Watcher.Sync.SetTaskSchedule(_task, null, CheckPeriodDialogEffective, true);
SyncStateDialog dlg = new SyncStateDialog(this);
SyncStateDialog dlg = new SyncStateDialog(this, account);
dlg.FormClosed += (s, e) =>
{
// Restore the schedule
@ -733,5 +736,43 @@ namespace Acacia.Features.SyncState
{
return new SyncStateImpl(this, account == null ? Watcher.Accounts.GetAccounts().ToArray() : new ZPushAccount[] { account });
}
private class SetDeviceOptionsRequest : SoapRequest<bool>
{
public SetDeviceOptionsRequest(SyncTimeFrame timeFrame)
{
Parameters.Add("filtertype", (int)timeFrame);
}
}
public void SetDeviceOptions(ZPushAccount account, SyncTimeFrame timeFrame)
{
try
{
Logger.Instance.Debug(this, "Setting sync time frame for {0} to {1}", account, timeFrame);
// First set the server value.
using (ZPushConnection connection = account.Connect())
using (ZPushWebServiceDevice deviceService = connection.DeviceService)
{
deviceService.Execute(new SetDeviceOptionsRequest(timeFrame));
}
// And the local value
account.SyncTimeFrame = timeFrame;
Logger.Instance.Debug(this, "Set sync time frame for {0} to {1}", account, timeFrame);
// Sync
ThisAddIn.Instance.SendReceive(account.Account);
}
catch (Exception x)
{
Logger.Instance.Warning(this, "Exception setting sync time frame for {0} to {1}: {2}", account, timeFrame, x);
}
}
}
}

View File

@ -38,6 +38,11 @@
this._labelProgress = new System.Windows.Forms.Label();
this.progress = new Acacia.Controls.KProgressBar();
this.textRemaining = new System.Windows.Forms.Label();
this._labelTimeFrame = new System.Windows.Forms.Label();
this._layoutTimeFrameButtons = new System.Windows.Forms.TableLayoutPanel();
this.comboTimeFrame = new System.Windows.Forms.ComboBox();
this.buttonApplyTimeFrame = new System.Windows.Forms.Button();
this.buttonResetTimeFrame = new System.Windows.Forms.Button();
this._labelResync = new System.Windows.Forms.Label();
this.buttonGAB = new Acacia.Controls.KHintButton();
this.buttonSignatures = new Acacia.Controls.KHintButton();
@ -46,6 +51,7 @@
this._labelResyncOption = new System.Windows.Forms.Label();
this._layout.SuspendLayout();
this._layoutMain.SuspendLayout();
this._layoutTimeFrameButtons.SuspendLayout();
this.SuspendLayout();
//
// _layout
@ -73,12 +79,14 @@
this._layoutMain.Controls.Add(this._labelProgress, 0, 1);
this._layoutMain.Controls.Add(this.progress, 1, 1);
this._layoutMain.Controls.Add(this.textRemaining, 1, 2);
this._layoutMain.Controls.Add(this._labelResync, 0, 3);
this._layoutMain.Controls.Add(this.buttonGAB, 1, 3);
this._layoutMain.Controls.Add(this.buttonSignatures, 1, 4);
this._layoutMain.Controls.Add(this.buttonServerData, 1, 5);
this._layoutMain.Controls.Add(this.buttonFullResync, 1, 6);
this._layoutMain.Controls.Add(this._labelResyncOption, 1, 7);
this._layoutMain.Controls.Add(this._labelTimeFrame, 0, 3);
this._layoutMain.Controls.Add(this._layoutTimeFrameButtons, 1, 3);
this._layoutMain.Controls.Add(this._labelResync, 0, 6);
this._layoutMain.Controls.Add(this.buttonGAB, 1, 6);
this._layoutMain.Controls.Add(this.buttonSignatures, 1, 7);
this._layoutMain.Controls.Add(this.buttonServerData, 1, 8);
this._layoutMain.Controls.Add(this.buttonFullResync, 1, 9);
this._layoutMain.Controls.Add(this._labelResyncOption, 1, 10);
this._layoutMain.Name = "_layoutMain";
//
// _labelRemaining
@ -121,6 +129,50 @@
this.textRemaining.BackColor = System.Drawing.SystemColors.Window;
this.textRemaining.Name = "textRemaining";
//
// _labelTimeFrame
//
resources.ApplyResources(this._labelTimeFrame, "_labelTimeFrame");
this._labelTimeFrame.Name = "_labelTimeFrame";
//
// _layoutTimeFrameButtons
//
resources.ApplyResources(this._layoutTimeFrameButtons, "_layoutTimeFrameButtons");
this._layoutTimeFrameButtons.Controls.Add(this.comboTimeFrame, 0, 0);
this._layoutTimeFrameButtons.Controls.Add(this.buttonApplyTimeFrame, 2, 0);
this._layoutTimeFrameButtons.Controls.Add(this.buttonResetTimeFrame, 1, 0);
this._layoutTimeFrameButtons.Name = "_layoutTimeFrameButtons";
//
// comboTimeFrame
//
resources.ApplyResources(this.comboTimeFrame, "comboTimeFrame");
this.comboTimeFrame.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboTimeFrame.FormattingEnabled = true;
this.comboTimeFrame.Items.AddRange(new object[] {
resources.GetString("comboTimeFrame.Items"),
resources.GetString("comboTimeFrame.Items1"),
resources.GetString("comboTimeFrame.Items2"),
resources.GetString("comboTimeFrame.Items3"),
resources.GetString("comboTimeFrame.Items4"),
resources.GetString("comboTimeFrame.Items5"),
resources.GetString("comboTimeFrame.Items6"),
resources.GetString("comboTimeFrame.Items7")});
this.comboTimeFrame.Name = "comboTimeFrame";
this.comboTimeFrame.SelectedIndexChanged += new System.EventHandler(this.comboTimeFrame_SelectedIndexChanged);
//
// buttonApplyTimeFrame
//
resources.ApplyResources(this.buttonApplyTimeFrame, "buttonApplyTimeFrame");
this.buttonApplyTimeFrame.Name = "buttonApplyTimeFrame";
this.buttonApplyTimeFrame.UseVisualStyleBackColor = true;
this.buttonApplyTimeFrame.Click += new System.EventHandler(this.buttonApplyTimeFrame_Click);
//
// buttonResetTimeFrame
//
resources.ApplyResources(this.buttonResetTimeFrame, "buttonResetTimeFrame");
this.buttonResetTimeFrame.Name = "buttonResetTimeFrame";
this.buttonResetTimeFrame.UseVisualStyleBackColor = true;
this.buttonResetTimeFrame.Click += new System.EventHandler(this.buttonResetTimeFrame_Click);
//
// _labelResync
//
resources.ApplyResources(this._labelResync, "_labelResync");
@ -179,6 +231,7 @@
this._layout.PerformLayout();
this._layoutMain.ResumeLayout(false);
this._layoutMain.PerformLayout();
this._layoutTimeFrameButtons.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -201,5 +254,10 @@
private System.Windows.Forms.Label _labelResyncOption;
private System.Windows.Forms.Label _labelResync;
private Controls.KHintButton buttonGAB;
private System.Windows.Forms.Label _labelTimeFrame;
private System.Windows.Forms.ComboBox comboTimeFrame;
private System.Windows.Forms.TableLayoutPanel _layoutTimeFrameButtons;
private System.Windows.Forms.Button buttonApplyTimeFrame;
private System.Windows.Forms.Button buttonResetTimeFrame;
}
}

View File

@ -1,4 +1,4 @@
/// Copyright 2017 Kopano b.v.
/// Copyright 2018 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
@ -25,6 +25,7 @@ using System.Windows.Forms;
using Acacia.UI;
using Acacia.Controls;
using Acacia.ZPush;
using Acacia.ZPush.Connect;
namespace Acacia.Features.SyncState
{
@ -35,7 +36,15 @@ namespace Acacia.Features.SyncState
private readonly Button[] _syncButtons;
public SyncStateDialog(FeatureSyncState feature)
private ZPushAccount SelectedAccount
{
get
{
return comboAccounts.SelectedItem as ZPushAccount;
}
}
public SyncStateDialog(FeatureSyncState feature, ZPushAccount currentAccount)
{
InitializeComponent();
@ -50,6 +59,8 @@ namespace Acacia.Features.SyncState
// Add the accounts
foreach (ZPushAccount account in ThisAddIn.Instance.Watcher.Accounts.GetAccounts())
comboAccounts.Items.Add(account);
if (currentAccount != null)
comboAccounts.SelectedItem = currentAccount;
}
private void ShowHint(object sender, KHintButton.HintEventArgs e)
@ -57,12 +68,60 @@ namespace Acacia.Features.SyncState
_labelResyncOption.Text = e.Hint ?? string.Empty;
}
#region Sync time frame
private void comboAccounts_SelectedIndexChanged(object sender, EventArgs e)
{
_syncState = _feature.GetSyncState(comboAccounts.SelectedItem as ZPushAccount);
_syncState = _feature.GetSyncState(SelectedAccount);
_labelTimeFrame.Enabled = comboTimeFrame.Enabled = SelectedAccount != null;
if (SelectedAccount == null)
comboTimeFrame.SelectedIndex = 0;
else
comboTimeFrame.SelectedIndex = (int)SelectedAccount.SyncTimeFrame;
UpdateUI();
}
private void comboTimeFrame_SelectedIndexChanged(object sender, EventArgs e)
{
CheckTimeFrameDirty();
}
private void CheckTimeFrameDirty()
{
if (SelectedAccount != null)
{
SyncTimeFrame timeFrame = (SyncTimeFrame)comboTimeFrame.SelectedIndex;
bool isDirty = timeFrame != SelectedAccount.SyncTimeFrame;
buttonApplyTimeFrame.Enabled = buttonResetTimeFrame.Enabled = isDirty;
}
else
{
buttonApplyTimeFrame.Enabled = buttonResetTimeFrame.Enabled = false;
}
}
private void buttonResetTimeFrame_Click(object sender, EventArgs e)
{
if (SelectedAccount != null)
comboTimeFrame.SelectedIndex = (int)SelectedAccount.SyncTimeFrame;
}
private void buttonApplyTimeFrame_Click(object sender, EventArgs e)
{
if (SelectedAccount != null)
{
Busy = true;
// TODO: do this in the background
_feature.SetDeviceOptions(SelectedAccount, (SyncTimeFrame)comboTimeFrame.SelectedIndex);
CheckTimeFrameDirty();
}
}
#endregion
private static readonly string[] OPTION_TEXT =
{
Properties.Resources.SyncState_Resync_Body_GAB,
@ -150,5 +209,6 @@ namespace Acacia.Features.SyncState
progress.Value = 100;
}
}
}
}

View File

@ -139,13 +139,13 @@
</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>5, 711</value>
<value>2, 344</value>
</data>
<data name="_buttons.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>5, 5, 5, 5</value>
<value>2, 2, 2, 2</value>
</data>
<data name="_buttons.Size" type="System.Drawing.Size, System.Drawing">
<value>889, 54</value>
<value>333, 35</value>
</data>
<data name="_buttons.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -181,13 +181,10 @@
<value>NoControl</value>
</data>
<data name="_labelRemaining.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 129</value>
</data>
<data name="_labelRemaining.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 0, 8, 0</value>
<value>3, 59</value>
</data>
<data name="_labelRemaining.Size" type="System.Drawing.Size, System.Drawing">
<value>203, 60</value>
<value>77, 25</value>
</data>
<data name="_labelRemaining.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -217,13 +214,10 @@
<value>Fill</value>
</data>
<data name="_labelAccount.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 0</value>
</data>
<data name="_labelAccount.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 0, 8, 0</value>
<value>3, 0</value>
</data>
<data name="_labelAccount.Size" type="System.Drawing.Size, System.Drawing">
<value>203, 53</value>
<value>77, 27</value>
</data>
<data name="_labelAccount.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -256,16 +250,13 @@
<value>All Z-Push accounts</value>
</data>
<data name="comboAccounts.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 7</value>
</data>
<data name="comboAccounts.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>86, 3</value>
</data>
<data name="comboAccounts.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 39</value>
<value>242, 21</value>
</data>
<data name="comboAccounts.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
<value>0</value>
</data>
<data name="&gt;&gt;comboAccounts.Name" xml:space="preserve">
<value>comboAccounts</value>
@ -286,13 +277,10 @@
<value>Fill</value>
</data>
<data name="_labelProgress.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 53</value>
</data>
<data name="_labelProgress.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 0, 8, 0</value>
<value>3, 27</value>
</data>
<data name="_labelProgress.Size" type="System.Drawing.Size, System.Drawing">
<value>203, 76</value>
<value>77, 32</value>
</data>
<data name="_labelProgress.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -319,16 +307,13 @@
<value>Fill</value>
</data>
<data name="progress.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 60</value>
</data>
<data name="progress.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>86, 30</value>
</data>
<data name="progress.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 62</value>
<value>242, 26</value>
</data>
<data name="progress.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
<value>1</value>
</data>
<data name="&gt;&gt;progress.Name" xml:space="preserve">
<value>progress</value>
@ -349,19 +334,19 @@
<value>Fill</value>
</data>
<data name="textRemaining.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 136</value>
<value>86, 62</value>
</data>
<data name="textRemaining.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>3, 3, 3, 3</value>
</data>
<data name="textRemaining.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>3, 3, 3, 3</value>
</data>
<data name="textRemaining.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 46</value>
<value>242, 19</value>
</data>
<data name="textRemaining.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
<value>2</value>
</data>
<data name="&gt;&gt;textRemaining.Name" xml:space="preserve">
<value>textRemaining</value>
@ -375,6 +360,183 @@
<data name="&gt;&gt;textRemaining.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="_labelTimeFrame.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="_labelTimeFrame.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_labelTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 84</value>
</data>
<data name="_labelTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 28</value>
</data>
<data name="_labelTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="_labelTimeFrame.Text" xml:space="preserve">
<value>Synchronise</value>
</data>
<data name="_labelTimeFrame.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="&gt;&gt;_labelTimeFrame.Name" xml:space="preserve">
<value>_labelTimeFrame</value>
</data>
<data name="&gt;&gt;_labelTimeFrame.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;_labelTimeFrame.Parent" xml:space="preserve">
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;_labelTimeFrame.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="_layoutTimeFrameButtons.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="_layoutTimeFrameButtons.ColumnCount" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="comboTimeFrame.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="comboTimeFrame.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<value>Popup</value>
</data>
<data name="comboTimeFrame.Items" xml:space="preserve">
<value>all</value>
</data>
<data name="comboTimeFrame.Items1" xml:space="preserve">
<value>1 day</value>
</data>
<data name="comboTimeFrame.Items2" xml:space="preserve">
<value>3 days</value>
</data>
<data name="comboTimeFrame.Items3" xml:space="preserve">
<value>1 week</value>
</data>
<data name="comboTimeFrame.Items4" xml:space="preserve">
<value>2 weeks</value>
</data>
<data name="comboTimeFrame.Items5" xml:space="preserve">
<value>1 month</value>
</data>
<data name="comboTimeFrame.Items6" xml:space="preserve">
<value>3 months</value>
</data>
<data name="comboTimeFrame.Items7" xml:space="preserve">
<value>6 months</value>
</data>
<data name="comboTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>
<data name="comboTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>102, 21</value>
</data>
<data name="comboTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;comboTimeFrame.Name" xml:space="preserve">
<value>comboTimeFrame</value>
</data>
<data name="&gt;&gt;comboTimeFrame.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;comboTimeFrame.Parent" xml:space="preserve">
<value>_layoutTimeFrameButtons</value>
</data>
<data name="&gt;&gt;comboTimeFrame.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="buttonApplyTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>181, 2</value>
</data>
<data name="buttonApplyTimeFrame.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 3</value>
</data>
<data name="buttonApplyTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>64, 23</value>
</data>
<data name="buttonApplyTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="buttonApplyTimeFrame.Text" xml:space="preserve">
<value>Apply</value>
</data>
<data name="&gt;&gt;buttonApplyTimeFrame.Name" xml:space="preserve">
<value>buttonApplyTimeFrame</value>
</data>
<data name="&gt;&gt;buttonApplyTimeFrame.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonApplyTimeFrame.Parent" xml:space="preserve">
<value>_layoutTimeFrameButtons</value>
</data>
<data name="&gt;&gt;buttonApplyTimeFrame.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="buttonResetTimeFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>111, 2</value>
</data>
<data name="buttonResetTimeFrame.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 3</value>
</data>
<data name="buttonResetTimeFrame.Size" type="System.Drawing.Size, System.Drawing">
<value>64, 23</value>
</data>
<data name="buttonResetTimeFrame.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="buttonResetTimeFrame.Text" xml:space="preserve">
<value>Reset</value>
</data>
<data name="&gt;&gt;buttonResetTimeFrame.Name" xml:space="preserve">
<value>buttonResetTimeFrame</value>
</data>
<data name="&gt;&gt;buttonResetTimeFrame.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonResetTimeFrame.Parent" xml:space="preserve">
<value>_layoutTimeFrameButtons</value>
</data>
<data name="&gt;&gt;buttonResetTimeFrame.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="_layoutTimeFrameButtons.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_layoutTimeFrameButtons.Location" type="System.Drawing.Point, System.Drawing">
<value>83, 84</value>
</data>
<data name="_layoutTimeFrameButtons.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="_layoutTimeFrameButtons.RowCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="_layoutTimeFrameButtons.Size" type="System.Drawing.Size, System.Drawing">
<value>248, 28</value>
</data>
<data name="_layoutTimeFrameButtons.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;_layoutTimeFrameButtons.Name" xml:space="preserve">
<value>_layoutTimeFrameButtons</value>
</data>
<data name="&gt;&gt;_layoutTimeFrameButtons.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;_layoutTimeFrameButtons.Parent" xml:space="preserve">
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;_layoutTimeFrameButtons.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="_layoutTimeFrameButtons.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="comboTimeFrame" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="buttonApplyTimeFrame" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="buttonResetTimeFrame" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100,AutoSize,0,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="_labelResync.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -382,13 +544,10 @@
<value>Fill</value>
</data>
<data name="_labelResync.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 189</value>
</data>
<data name="_labelResync.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 0, 8, 0</value>
<value>3, 132</value>
</data>
<data name="_labelResync.Size" type="System.Drawing.Size, System.Drawing">
<value>203, 70</value>
<value>77, 35</value>
</data>
<data name="_labelResync.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -409,7 +568,7 @@
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;_labelResync.ZOrder" xml:space="preserve">
<value>6</value>
<value>8</value>
</data>
<data name="buttonGAB.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -427,19 +586,16 @@
<value>NoControl</value>
</data>
<data name="buttonGAB.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 196</value>
</data>
<data name="buttonGAB.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>86, 135</value>
</data>
<data name="buttonGAB.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>3, 3, 3, 3</value>
</data>
<data name="buttonGAB.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 56</value>
<value>242, 29</value>
</data>
<data name="buttonGAB.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
<value>4</value>
</data>
<data name="buttonGAB.Text" xml:space="preserve">
<value>Global Address Book</value>
@ -454,7 +610,7 @@
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;buttonGAB.ZOrder" xml:space="preserve">
<value>7</value>
<value>9</value>
</data>
<data name="buttonSignatures.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -472,19 +628,16 @@
<value>NoControl</value>
</data>
<data name="buttonSignatures.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 266</value>
</data>
<data name="buttonSignatures.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>86, 170</value>
</data>
<data name="buttonSignatures.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>3, 3, 3, 3</value>
</data>
<data name="buttonSignatures.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 56</value>
<value>242, 29</value>
</data>
<data name="buttonSignatures.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
<value>5</value>
</data>
<data name="buttonSignatures.Text" xml:space="preserve">
<value>Signatures</value>
@ -499,7 +652,7 @@
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;buttonSignatures.ZOrder" xml:space="preserve">
<value>8</value>
<value>10</value>
</data>
<data name="buttonServerData.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -517,19 +670,16 @@
<value>NoControl</value>
</data>
<data name="buttonServerData.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 336</value>
</data>
<data name="buttonServerData.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>86, 205</value>
</data>
<data name="buttonServerData.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>3, 3, 3, 3</value>
</data>
<data name="buttonServerData.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 56</value>
<value>242, 29</value>
</data>
<data name="buttonServerData.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
<value>6</value>
</data>
<data name="buttonServerData.Text" xml:space="preserve">
<value>Server Data</value>
@ -544,7 +694,7 @@
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;buttonServerData.ZOrder" xml:space="preserve">
<value>9</value>
<value>11</value>
</data>
<data name="buttonFullResync.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -562,19 +712,16 @@
<value>NoControl</value>
</data>
<data name="buttonFullResync.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 406</value>
</data>
<data name="buttonFullResync.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>86, 240</value>
</data>
<data name="buttonFullResync.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>3, 3, 3, 3</value>
</data>
<data name="buttonFullResync.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 56</value>
<value>242, 29</value>
</data>
<data name="buttonFullResync.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
<value>7</value>
</data>
<data name="buttonFullResync.Text" xml:space="preserve">
<value>Full Resynchronisation</value>
@ -589,22 +736,19 @@
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;buttonFullResync.ZOrder" xml:space="preserve">
<value>10</value>
<value>12</value>
</data>
<data name="_labelResyncOption.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_labelResyncOption.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 469</value>
</data>
<data name="_labelResyncOption.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 0, 8, 0</value>
<value>86, 272</value>
</data>
<data name="_labelResyncOption.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 14, 0, 0</value>
<value>0, 6, 0, 0</value>
</data>
<data name="_labelResyncOption.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 223</value>
<value>242, 64</value>
</data>
<data name="_labelResyncOption.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -619,22 +763,19 @@
<value>_layoutMain</value>
</data>
<data name="&gt;&gt;_labelResyncOption.ZOrder" xml:space="preserve">
<value>11</value>
<value>13</value>
</data>
<data name="_layoutMain.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_layoutMain.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 7</value>
</data>
<data name="_layoutMain.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>3, 3</value>
</data>
<data name="_layoutMain.RowCount" type="System.Int32, mscorlib">
<value>8</value>
<value>11</value>
</data>
<data name="_layoutMain.Size" type="System.Drawing.Size, System.Drawing">
<value>883, 692</value>
<value>331, 336</value>
</data>
<data name="_layoutMain.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -652,7 +793,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="_labelResync" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="buttonGAB" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonSignatures" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonServerData" Row="5" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="buttonFullResync" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelResyncOption" Row="7" 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,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,20,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>
@ -660,14 +801,11 @@
<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>8, 7, 8, 7</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>899, 770</value>
<value>337, 381</value>
</data>
<data name="_layout.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -691,16 +829,13 @@
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>16, 31</value>
<value>6, 13</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>899, 770</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>8, 7, 8, 7</value>
<value>337, 381</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>

View File

@ -1,6 +1,4 @@

using Acacia.Native.MAPI;
/// Copyright 2016 Kopano b.v.
/// Copyright 2018 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,

View File

@ -8,12 +8,17 @@ using System.Threading.Tasks;
namespace Acacia.Native
{
[StructLayout(LayoutKind.Sequential)]
[StructLayout(LayoutKind.Explicit)]
unsafe public struct ACCT_VARIANT
{
[FieldOffset(0), MarshalAs(UnmanagedType.U4)]
public uint dwType;
[FieldOffset(8)]
public char* lpszW;
[FieldOffset(8), MarshalAs(UnmanagedType.U4)]
public uint dw;
}
[ComImport]

View File

@ -55,6 +55,15 @@ namespace Acacia.Native.MAPI
return new SearchQuery.PropertyIdentifier(this);
}
public static PropTag FromValue(ushort prop, PropType type)
{
return new PropTag()
{
prop = prop,
type = type
};
}
public static PropTag FromInt(int v)
{
return new PropTag()

View File

@ -1,4 +1,6 @@
/// Copyright 2016 Kopano b.v.

using Acacia.Native.MAPI;
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
@ -13,7 +15,6 @@
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
@ -45,9 +46,15 @@ namespace Acacia
public const string REG_VAL_REPLY_FORWARD_SIGNATURE = "Reply-Forward Signature";
public const string REG_VAL_CURRENT_SIGNATURE = "KOE Signature Digest";
public const string REG_VAL_SYNC_TIMEFRAME = "KOE SyncTimeFrame";
public const string REG_VAL_SYNC_SLIDER = "EAS SyncSlider";
public const string REG_VAL_NEXT_ACCOUNT_ID = "NextAccountID";
public const string REG_VAL_KOE_SHARE_FOR = "KOE Share For";
public static readonly PropTag PROP_NEW_MESSAGE_SIGNATURE = PropTag.FromValue(0x0016, PropType.UNICODE);
public static readonly PropTag PROP_REPLY_SIGNATURE = PropTag.FromValue(0x0017, PropType.UNICODE);
public static readonly PropTag PROP_SYNC_1_MONTH = PropTag.FromValue(0x2103, PropType.LONG);
#endregion
#region PREFIXES

View File

@ -1,4 +1,6 @@
/// Copyright 2017 Kopano b.v.

using Acacia.Native.MAPI;
/// Copyright 2017 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
@ -13,7 +15,6 @@
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
@ -54,25 +55,8 @@ namespace Acacia.Stubs
string BackingFilePath { get; }
// TODO: this is really a Z-Push thing, but it's here to store it in the registry
string LocalSignaturesHash
{
get;
set;
}
string RegistryBaseKey { get; }
string SignatureNewMessage
{
get;
set;
}
string SignatureReplyForwardMessage
{
get;
set;
}
string ShareFor {get;}
void SetAccountProp(PropTag prop, object value);
}
}

View File

@ -1,7 +1,5 @@

using Acacia.Native;
using Acacia.Native.MAPI;
/// Copyright 2017 Kopano b.v.
/// Copyright 2018 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
@ -17,6 +15,8 @@ using Acacia.Native.MAPI;
///
/// Consult LICENSE file for details
using Acacia.Utils;
using Acacia.Native;
using Acacia.Native.MAPI;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
@ -207,55 +207,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
public string LocalSignaturesHash
{
get
{
return RegistryUtil.GetValueString(_regPath, OutlookConstants.REG_VAL_CURRENT_SIGNATURE, null);
}
set
{
RegistryUtil.SetValueString(_regPath, OutlookConstants.REG_VAL_CURRENT_SIGNATURE, value);
}
}
public string SignatureNewMessage
{
get
{
return RegistryUtil.GetValueString(_regPath, OutlookConstants.REG_VAL_NEW_SIGNATURE, null);
}
set
{
// TODO: constant for account
SetAccountProp(PropTag.FromInt(0x0016001F), value);
}
}
unsafe private void SetAccountProp(PropTag propTag, string value)
{
// Use IOlkAccount to notify while we're running
// IOlkAccount can only be accessed on main thread
ThisAddIn.Instance.InUI(() =>
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Account account = com.Add(FindAccountObject());
IOlkAccount olk = com.Add(account.IOlkAccount);
fixed (char* ptr = value.ToCharArray())
{
ACCT_VARIANT val = new ACCT_VARIANT()
{
dwType = (uint)PropType.UNICODE,
lpszW = ptr
};
olk.SetProp(propTag, &val);
olk.SaveChanges(0);
}
}
});
}
private NSOutlook.Account FindAccountObject()
{
using (ComRelease com = new ComRelease())
@ -272,26 +223,50 @@ namespace Acacia.Stubs.OutlookWrappers
return null;
}
public string SignatureReplyForwardMessage
{
get
{
return RegistryUtil.GetValueString(_regPath, OutlookConstants.REG_VAL_REPLY_FORWARD_SIGNATURE, null);
}
set
{
SetAccountProp(PropTag.FromInt(0x0017001F), value);
}
}
public string ShareFor
unsafe public void SetAccountProp(PropTag propTag, object value)
{
get
// Use IOlkAccount to notify while we're running
// IOlkAccount can only be accessed on main thread
ThisAddIn.Instance.InUI(() =>
{
return RegistryUtil.GetValueString(_regPath, OutlookConstants.REG_VAL_KOE_SHARE_FOR, null);
}
using (ComRelease com = new ComRelease())
{
NSOutlook.Account account = com.Add(FindAccountObject());
IOlkAccount olk = com.Add(account.IOlkAccount);
switch(propTag.type)
{
case PropType.UNICODE:
fixed (char* ptr = ((string)value).ToCharArray())
{
ACCT_VARIANT val = new ACCT_VARIANT()
{
dwType = (uint)PropType.UNICODE,
lpszW = ptr
};
olk.SetProp(propTag, &val);
olk.SaveChanges(0);
}
break;
case PropType.LONG:
{
ACCT_VARIANT val = new ACCT_VARIANT()
{
dwType = (uint)PropType.LONG,
dw = (uint)value
};
olk.SetProp(propTag, &val);
olk.SaveChanges(0);
break;
}
}
}
});
}
#endregion
public string RegistryBaseKey { get { return _regPath; } }
}
}

View File

@ -45,6 +45,17 @@ namespace Acacia.Utils
Registry.SetValue(keyPath, valueName, value);
}
public static int GetValueDword(string keyPath, string valueName, int defaultValue)
{
object o = Registry.GetValue(keyPath, valueName, defaultValue);
return (int)o;
}
public static void SetValueDword(string keyPath, string valueName, int value)
{
Registry.SetValue(keyPath, valueName, value);
}
public static string RegToString(object o)
{
if (o is byte[])

View File

@ -1,4 +1,5 @@
/// Copyright 2016 Kopano b.v.

/// Copyright 2018 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
@ -13,7 +14,6 @@
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
///
/// Consult LICENSE file for details
using Acacia.Stubs;
using Acacia.Stubs.OutlookWrappers;
using Acacia.Utils;
@ -28,6 +28,9 @@ using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Acacia.Native;
using Acacia.Native.MAPI;
using NSOutlook = Microsoft.Office.Interop.Outlook;
namespace Acacia.ZPush
{
@ -213,7 +216,10 @@ namespace Acacia.ZPush
public string ShareFor
{
get { return Account.ShareFor; }
get
{
return RegistryUtil.GetValueString(Account.RegistryBaseKey, OutlookConstants.REG_VAL_KOE_SHARE_FOR, null);
}
}
public string ShareUserName
@ -235,10 +241,10 @@ namespace Acacia.ZPush
{
get
{
if (Account.ShareFor == null)
if (ShareFor == null)
return null;
return _zPushAccounts.GetAccount(Account.ShareFor);
return _zPushAccounts.GetAccount(ShareFor);
}
}
@ -284,5 +290,102 @@ namespace Acacia.ZPush
}
#endregion
#region Signatures
public string LocalSignaturesHash
{
get
{
return RegistryUtil.GetValueString(Account.RegistryBaseKey, OutlookConstants.REG_VAL_CURRENT_SIGNATURE, null);
}
set
{
RegistryUtil.SetValueString(Account.RegistryBaseKey, OutlookConstants.REG_VAL_CURRENT_SIGNATURE, value);
}
}
public string SignatureNewMessage
{
get
{
return RegistryUtil.GetValueString(Account.RegistryBaseKey, OutlookConstants.REG_VAL_NEW_SIGNATURE, null);
}
set
{
Account.SetAccountProp(OutlookConstants.PROP_NEW_MESSAGE_SIGNATURE, value);
}
}
public string SignatureReplyForwardMessage
{
get
{
return RegistryUtil.GetValueString(Account.RegistryBaseKey, OutlookConstants.REG_VAL_REPLY_FORWARD_SIGNATURE, null);
}
set
{
Account.SetAccountProp(OutlookConstants.PROP_REPLY_SIGNATURE, value);
}
}
#endregion
#region Sync time frame
public SyncTimeFrame SyncTimeFrame
{
get
{
int val = RegistryUtil.GetValueDword(Account.RegistryBaseKey, OutlookConstants.REG_VAL_SYNC_TIMEFRAME, -1);
// Check for default (Outlook) values
if (val < 0)
{
if (EASSyncOneMonth)
return SyncTimeFrame.MONTH_1;
return SyncTimeFrame.ALL;
}
SyncTimeFrame frame = (SyncTimeFrame)val;
// If the timeframe exceeds one month, but Outlook is set to one month, only one month will be synced.
if (!IsSyncOneMonthOrLess(frame) && EASSyncOneMonth)
return SyncTimeFrame.MONTH_1;
return frame;
}
set
{
if (value != SyncTimeFrame)
{
// Set the outlook property
EASSyncOneMonth = IsSyncOneMonthOrLess(value);
// And the registry value
RegistryUtil.SetValueDword(Account.RegistryBaseKey, OutlookConstants.REG_VAL_SYNC_TIMEFRAME, (int)value);
}
}
}
private bool EASSyncOneMonth
{
get
{
return RegistryUtil.GetValueDword(Account.RegistryBaseKey, OutlookConstants.REG_VAL_SYNC_SLIDER, -1) == 1;
}
set
{
if (value != EASSyncOneMonth)
{
Account.SetAccountProp(OutlookConstants.PROP_SYNC_1_MONTH, value ? (uint)1 : (uint)0);
}
}
}
private bool IsSyncOneMonthOrLess(SyncTimeFrame sync)
{
return sync <= SyncTimeFrame.MONTH_1 && sync != SyncTimeFrame.ALL;
}
#endregion
}
}

View File

@ -132,4 +132,17 @@ namespace Acacia.ZPush
#endregion
}
public enum SyncTimeFrame
{
// The order of this is to match the Z-Push settings
ALL,
DAY_1,
DAY_3,
WEEK_1,
WEEK_2,
MONTH_1,
MONTH_3,
MONTH_6
}
}