mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Cleaned up MailEvent release. Added debug option to GAB to prevent MailEvent hooking.
This commit is contained in:
parent
471b9c80c7
commit
d7df634a3d
@ -64,8 +64,11 @@ namespace Acacia.Features.GAB
|
|||||||
|
|
||||||
public override void Startup()
|
public override void Startup()
|
||||||
{
|
{
|
||||||
MailEvents.BeforeDelete += SuppressEventHandler_Delete;
|
if (SuppressModifications)
|
||||||
MailEvents.Write += SuppressEventHandler_Modify;
|
{
|
||||||
|
MailEvents.BeforeDelete += SuppressEventHandler_Delete;
|
||||||
|
MailEvents.Write += SuppressEventHandler_Modify;
|
||||||
|
}
|
||||||
Watcher.AccountDiscovered += AccountDiscovered;
|
Watcher.AccountDiscovered += AccountDiscovered;
|
||||||
Watcher.AccountRemoved += AccountRemoved;
|
Watcher.AccountRemoved += AccountRemoved;
|
||||||
Watcher.AccountsScanned += AccountsScanned;
|
Watcher.AccountsScanned += AccountsScanned;
|
||||||
@ -208,7 +211,16 @@ namespace Acacia.Features.GAB
|
|||||||
set { SetOption(OPTION_EMPTY_DELETED_ITEMS, value); }
|
set { SetOption(OPTION_EMPTY_DELETED_ITEMS, value); }
|
||||||
}
|
}
|
||||||
private static readonly BoolOption OPTION_EMPTY_DELETED_ITEMS = new BoolOption("EmptyDeletedItems", true);
|
private static readonly BoolOption OPTION_EMPTY_DELETED_ITEMS = new BoolOption("EmptyDeletedItems", true);
|
||||||
|
|
||||||
|
[AcaciaOption("If enabled, modifications to the GAB folder are suppressed. " +
|
||||||
|
"This should only be disabled for debug purposes.")]
|
||||||
|
public bool SuppressModifications
|
||||||
|
{
|
||||||
|
get { return GetOption(OPTION_SUPPRESS_MODIFICATIONS); }
|
||||||
|
set { SetOption(OPTION_SUPPRESS_MODIFICATIONS, value); }
|
||||||
|
}
|
||||||
|
private static readonly BoolOption OPTION_SUPPRESS_MODIFICATIONS = new BoolOption("SuppressModifications", true);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Modification suppression
|
#region Modification suppression
|
||||||
|
@ -35,6 +35,7 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
{
|
{
|
||||||
Interlocked.Increment(ref Statistics.CreatedWrappers);
|
Interlocked.Increment(ref Statistics.CreatedWrappers);
|
||||||
this._createdTrace = new System.Diagnostics.StackTrace();
|
this._createdTrace = new System.Diagnostics.StackTrace();
|
||||||
|
MustRelease = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ComWrapper()
|
~ComWrapper()
|
||||||
|
@ -219,25 +219,22 @@ namespace Acacia.Utils
|
|||||||
NSOutlook.ItemEvents_10_Event hasEvents = item as NSOutlook.ItemEvents_10_Event;
|
NSOutlook.ItemEvents_10_Event hasEvents = item as NSOutlook.ItemEvents_10_Event;
|
||||||
if (hasEvents != null)
|
if (hasEvents != null)
|
||||||
{
|
{
|
||||||
new MailEventHooker(item, hasEvents, this);
|
new MailEventHooker(hasEvents, this);
|
||||||
}
|
}
|
||||||
else ComRelease.Release(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MailEventHooker : ComWrapper
|
private class MailEventHooker : ComWrapper
|
||||||
{
|
{
|
||||||
private object _item;
|
|
||||||
private NSOutlook.ItemEvents_10_Event _itemEvents;
|
private NSOutlook.ItemEvents_10_Event _itemEvents;
|
||||||
private readonly MailEvents _events;
|
private readonly MailEvents _events;
|
||||||
// TODO: remove id and debug logging
|
// TODO: remove id and debug logging
|
||||||
private int _id;
|
private int _id;
|
||||||
private static int nextId;
|
private static int nextId;
|
||||||
|
|
||||||
public MailEventHooker(object item, NSOutlook.ItemEvents_10_Event itemEvents, MailEvents events)
|
public MailEventHooker(NSOutlook.ItemEvents_10_Event itemEvents, MailEvents events)
|
||||||
{
|
{
|
||||||
this._id = ++nextId;
|
|
||||||
this._item = item;
|
|
||||||
this._itemEvents = itemEvents;
|
this._itemEvents = itemEvents;
|
||||||
|
this._id = ++nextId;
|
||||||
this._events = events;
|
this._events = events;
|
||||||
HookEvents(true);
|
HookEvents(true);
|
||||||
}
|
}
|
||||||
@ -245,11 +242,8 @@ namespace Acacia.Utils
|
|||||||
protected override void DoRelease()
|
protected override void DoRelease()
|
||||||
{
|
{
|
||||||
Logger.Instance.Debug(this, "DoRelease: {0}", _id);
|
Logger.Instance.Debug(this, "DoRelease: {0}", _id);
|
||||||
|
// TODO: It looks like release _itemEvents is not only not needed, but causes exceptions.
|
||||||
ComRelease.Release(_item);
|
// If that is really the case, this doesn't need to be a ComWrapper
|
||||||
_item = null;
|
|
||||||
ComRelease.Release(_itemEvents);
|
|
||||||
_itemEvents = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HookEvents(bool add)
|
private void HookEvents(bool add)
|
||||||
|
Loading…
Reference in New Issue
Block a user