mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Cleaned up ZPushSync.
This commit is contained in:
parent
f913ed5a01
commit
d4b03c2eb9
@ -288,6 +288,7 @@
|
|||||||
<Compile Include="Stubs\IItemEvents.cs" />
|
<Compile Include="Stubs\IItemEvents.cs" />
|
||||||
<Compile Include="Stubs\IOutlookWindow.cs" />
|
<Compile Include="Stubs\IOutlookWindow.cs" />
|
||||||
<Compile Include="Stubs\IRecipient.cs" />
|
<Compile Include="Stubs\IRecipient.cs" />
|
||||||
|
<Compile Include="Stubs\ISyncObject.cs" />
|
||||||
<Compile Include="Stubs\OutlookWrappers\AddInWrapper.cs" />
|
<Compile Include="Stubs\OutlookWrappers\AddInWrapper.cs" />
|
||||||
<Compile Include="Stubs\OutlookWrappers\AddressEntryWrapper.cs" />
|
<Compile Include="Stubs\OutlookWrappers\AddressEntryWrapper.cs" />
|
||||||
<Compile Include="Stubs\OutlookWrappers\CommandBarsWrapper.cs" />
|
<Compile Include="Stubs\OutlookWrappers\CommandBarsWrapper.cs" />
|
||||||
@ -295,6 +296,7 @@
|
|||||||
<Compile Include="Stubs\OutlookWrappers\ItemEventsWrapper.cs" />
|
<Compile Include="Stubs\OutlookWrappers\ItemEventsWrapper.cs" />
|
||||||
<Compile Include="Stubs\OutlookWrappers\OutlookItemWrapper.cs" />
|
<Compile Include="Stubs\OutlookWrappers\OutlookItemWrapper.cs" />
|
||||||
<Compile Include="Stubs\OutlookWrappers\RecipientWrapper.cs" />
|
<Compile Include="Stubs\OutlookWrappers\RecipientWrapper.cs" />
|
||||||
|
<Compile Include="Stubs\OutlookWrappers\SyncObjectWrapper.cs" />
|
||||||
<Compile Include="Stubs\Wrappers.cs" />
|
<Compile Include="Stubs\Wrappers.cs" />
|
||||||
<Compile Include="UI\Outlook\OutlookImageList.cs" />
|
<Compile Include="UI\Outlook\OutlookImageList.cs" />
|
||||||
<Compile Include="UI\Outlook\RibbonToggleButton.cs" />
|
<Compile Include="UI\Outlook\RibbonToggleButton.cs" />
|
||||||
|
@ -21,6 +21,7 @@ namespace Acacia.Stubs
|
|||||||
IEnumerable<Feature> Features { get; }
|
IEnumerable<Feature> Features { get; }
|
||||||
IEnumerable<KeyValuePair<string,string>> COMAddIns { get; }
|
IEnumerable<KeyValuePair<string,string>> COMAddIns { get; }
|
||||||
string Version { get; }
|
string Version { get; }
|
||||||
|
ISyncObject GetSyncObject();
|
||||||
|
|
||||||
#region UI
|
#region UI
|
||||||
|
|
||||||
|
34
src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/ISyncObject.cs
Normal file
34
src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/ISyncObject.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NSOutlook = Microsoft.Office.Interop.Outlook;
|
||||||
|
|
||||||
|
namespace Acacia.Stubs
|
||||||
|
{
|
||||||
|
public interface ISyncObject : IComWrapper
|
||||||
|
{
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
string Name { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
// TODO: custom delegates
|
||||||
|
event NSOutlook.SyncObjectEvents_OnErrorEventHandler OnError;
|
||||||
|
event NSOutlook.SyncObjectEvents_ProgressEventHandler Progress;
|
||||||
|
event NSOutlook.SyncObjectEvents_SyncEndEventHandler SyncEnd;
|
||||||
|
event NSOutlook.SyncObjectEvents_SyncStartEventHandler SyncStart;
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -82,6 +82,16 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ISyncObject GetSyncObject()
|
||||||
|
{
|
||||||
|
using (ComRelease com = new ComRelease())
|
||||||
|
{
|
||||||
|
NSOutlook.NameSpace session = com.Add(_app.Session);
|
||||||
|
NSOutlook.SyncObjects syncObjects = com.Add(session.SyncObjects);
|
||||||
|
return new SyncObjectWrapper(syncObjects.AppFolders);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region UI
|
#region UI
|
||||||
|
|
||||||
public OutlookUI OutlookUI { get { return _thisAddIn.OutlookUI; } }
|
public OutlookUI OutlookUI { get { return _thisAddIn.OutlookUI; } }
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NSOutlook = Microsoft.Office.Interop.Outlook;
|
||||||
|
|
||||||
|
namespace Acacia.Stubs.OutlookWrappers
|
||||||
|
{
|
||||||
|
class SyncObjectWrapper : ComWrapper<NSOutlook.SyncObject>, ISyncObject
|
||||||
|
{
|
||||||
|
public SyncObjectWrapper(NSOutlook.SyncObject item) : base(item)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public string Name { get { return _item.Name; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
_item.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
_item.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
public event NSOutlook.SyncObjectEvents_OnErrorEventHandler OnError
|
||||||
|
{
|
||||||
|
add { _item.OnError += value; }
|
||||||
|
remove { _item.OnError -= value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public event NSOutlook.SyncObjectEvents_ProgressEventHandler Progress
|
||||||
|
{
|
||||||
|
add { _item.Progress += value; }
|
||||||
|
remove { _item.Progress -= value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public event NSOutlook.SyncObjectEvents_SyncEndEventHandler SyncEnd
|
||||||
|
{
|
||||||
|
add { _item.SyncEnd += value; }
|
||||||
|
remove { _item.SyncEnd -= value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public event NSOutlook.SyncObjectEvents_SyncStartEventHandler SyncStart
|
||||||
|
{
|
||||||
|
add { _item.SyncStart += value; }
|
||||||
|
remove { _item.SyncStart -= value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@
|
|||||||
/// Consult LICENSE file for details
|
/// Consult LICENSE file for details
|
||||||
|
|
||||||
using Acacia.Features;
|
using Acacia.Features;
|
||||||
|
using Acacia.Stubs;
|
||||||
using Acacia.Utils;
|
using Acacia.Utils;
|
||||||
using Acacia.ZPush.Connect;
|
using Acacia.ZPush.Connect;
|
||||||
using System;
|
using System;
|
||||||
@ -23,14 +24,13 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using NSOutlook = Microsoft.Office.Interop.Outlook;
|
|
||||||
|
|
||||||
namespace Acacia.ZPush
|
namespace Acacia.ZPush
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper for synchronising state with ZPush servers
|
/// Helper for synchronising state with ZPush servers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ZPushSync
|
public class ZPushSync : DisposableWrapper
|
||||||
{
|
{
|
||||||
#region SyncTask
|
#region SyncTask
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ namespace Acacia.ZPush
|
|||||||
|
|
||||||
#region Setup
|
#region Setup
|
||||||
|
|
||||||
private readonly NSOutlook.SyncObject _syncObject;
|
private readonly ISyncObject _syncObject;
|
||||||
private readonly Timer _timer;
|
private readonly Timer _timer;
|
||||||
private ZPushWatcher _watcher;
|
private ZPushWatcher _watcher;
|
||||||
private bool _started;
|
private bool _started;
|
||||||
@ -86,7 +86,7 @@ namespace Acacia.ZPush
|
|||||||
public readonly bool Enabled;
|
public readonly bool Enabled;
|
||||||
public readonly TimeSpan Period;
|
public readonly TimeSpan Period;
|
||||||
|
|
||||||
public ZPushSync(ZPushWatcher watcher, NSOutlook.Application app)
|
public ZPushSync(ZPushWatcher watcher, IAddIn addIn)
|
||||||
{
|
{
|
||||||
// Get the settings
|
// Get the settings
|
||||||
Enabled = GlobalOptions.INSTANCE.ZPushSync;
|
Enabled = GlobalOptions.INSTANCE.ZPushSync;
|
||||||
@ -104,12 +104,17 @@ namespace Acacia.ZPush
|
|||||||
_timer.Start();
|
_timer.Start();
|
||||||
|
|
||||||
// Need to keep a reference to keep receiving events
|
// Need to keep a reference to keep receiving events
|
||||||
_syncObject = app.Session.SyncObjects.AppFolders;
|
_syncObject = addIn.GetSyncObject();
|
||||||
_syncObject.SyncStart += SyncObject_SyncStart;
|
_syncObject.SyncStart += SyncObject_SyncStart;
|
||||||
watcher.AccountDiscovered += Watcher_AccountDiscovered;
|
watcher.AccountDiscovered += Watcher_AccountDiscovered;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void DoRelease()
|
||||||
|
{
|
||||||
|
_syncObject.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public interface
|
#region Public interface
|
||||||
|
@ -52,7 +52,7 @@ namespace Acacia.ZPush
|
|||||||
{
|
{
|
||||||
this._addIn = addIn;
|
this._addIn = addIn;
|
||||||
this._app = addIn.RawApp;
|
this._app = addIn.RawApp;
|
||||||
Sync = new ZPushSync(this, _app);
|
Sync = new ZPushSync(this, addIn);
|
||||||
Accounts = new ZPushAccounts(this, _app);
|
Accounts = new ZPushAccounts(this, _app);
|
||||||
|
|
||||||
// Need to keep a link to keep receiving events
|
// Need to keep a link to keep receiving events
|
||||||
|
Loading…
x
Reference in New Issue
Block a user