mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Added option to disable item event hooking
This commit is contained in:
parent
4dd77097a8
commit
90e0029a8e
@ -194,14 +194,11 @@ namespace Acacia.Features
|
|||||||
|
|
||||||
#region Event helpers
|
#region Event helpers
|
||||||
|
|
||||||
private static MailEvents _mailEvents;
|
|
||||||
protected static MailEvents MailEvents
|
protected static MailEvents MailEvents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_mailEvents == null)
|
return ThisAddIn.Instance.MailEvents;
|
||||||
_mailEvents = new MailEvents(ThisAddIn.Instance);
|
|
||||||
return _mailEvents;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace Acacia.Features.GAB
|
|||||||
|
|
||||||
public override void Startup()
|
public override void Startup()
|
||||||
{
|
{
|
||||||
if (SuppressModifications)
|
if (SuppressModifications && MailEvents != null)
|
||||||
{
|
{
|
||||||
MailEvents.BeforeDelete += SuppressEventHandler_Delete;
|
MailEvents.BeforeDelete += SuppressEventHandler_Delete;
|
||||||
MailEvents.Write += SuppressEventHandler_Modify;
|
MailEvents.Write += SuppressEventHandler_Modify;
|
||||||
|
@ -47,17 +47,23 @@ namespace Acacia.Features.ReplyFlags
|
|||||||
if (ReadEvent)
|
if (ReadEvent)
|
||||||
{
|
{
|
||||||
// As a fallback, add an event handler to update the message when displaying it
|
// As a fallback, add an event handler to update the message when displaying it
|
||||||
|
if (MailEvents != null)
|
||||||
|
{
|
||||||
MailEvents.Read += UpdateReplyStatus;
|
MailEvents.Read += UpdateReplyStatus;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SendEvents)
|
if (SendEvents)
|
||||||
{
|
{
|
||||||
// Hook reply and send events to update local state to server
|
// Hook reply and send events to update local state to server
|
||||||
|
if (MailEvents != null)
|
||||||
|
{
|
||||||
MailEvents.Reply += OnReply;
|
MailEvents.Reply += OnReply;
|
||||||
MailEvents.ReplyAll += OnReplyAll;
|
MailEvents.ReplyAll += OnReplyAll;
|
||||||
MailEvents.Forward += OnForwarded;
|
MailEvents.Forward += OnForwarded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override public void GetCapabilities(ZPushCapabilities caps)
|
override public void GetCapabilities(ZPushCapabilities caps)
|
||||||
{
|
{
|
||||||
|
@ -48,19 +48,25 @@ namespace Acacia.Features.SendAs
|
|||||||
private static readonly BoolOption OPTION_SEND_AS_OWNER = new BoolOption("SendAsOwner", true);
|
private static readonly BoolOption OPTION_SEND_AS_OWNER = new BoolOption("SendAsOwner", true);
|
||||||
|
|
||||||
public override void Startup()
|
public override void Startup()
|
||||||
|
{
|
||||||
|
if (MailEvents != null)
|
||||||
{
|
{
|
||||||
MailEvents.ItemSend += MailEvents_ItemSend;
|
MailEvents.ItemSend += MailEvents_ItemSend;
|
||||||
|
}
|
||||||
|
|
||||||
if (SendAsOwner)
|
if (SendAsOwner)
|
||||||
{
|
{
|
||||||
// Need shared folders for automatic sender selection
|
// Need shared folders for automatic sender selection
|
||||||
_sharedFolders = ThisAddIn.Instance.GetFeature<FeatureSharedFolders>();
|
_sharedFolders = ThisAddIn.Instance.GetFeature<FeatureSharedFolders>();
|
||||||
if (_sharedFolders != null)
|
if (_sharedFolders != null)
|
||||||
|
{
|
||||||
|
if (MailEvents != null)
|
||||||
{
|
{
|
||||||
MailEvents.Respond += MailEvents_Respond;
|
MailEvents.Respond += MailEvents_Respond;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MailEvents_Respond(IMailItem mail, IMailItem response)
|
private void MailEvents_Respond(IMailItem mail, IMailItem response)
|
||||||
{
|
{
|
||||||
|
@ -118,6 +118,15 @@ namespace Acacia
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AcaciaOption("Enables or disables item event hooking." +
|
||||||
|
"Note that if this is disabled, several features may not work correctly.")]
|
||||||
|
virtual public bool HookItemEvents
|
||||||
|
{
|
||||||
|
get { return GetOption(null, HOOK_ITEM_EVENTS); }
|
||||||
|
set { SetOption(null, HOOK_ITEM_EVENTS, value); }
|
||||||
|
}
|
||||||
|
private static readonly BoolOption HOOK_ITEM_EVENTS = new BoolOption("HookItemEvents", true);
|
||||||
|
|
||||||
#region UI Options
|
#region UI Options
|
||||||
|
|
||||||
[AcaciaOption("Completely enables or disables modifications to the Outlook UI." +
|
[AcaciaOption("Completely enables or disables modifications to the Outlook UI." +
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Acacia.Features;
|
using Acacia.Features;
|
||||||
using Acacia.UI.Outlook;
|
using Acacia.UI.Outlook;
|
||||||
|
using Acacia.Utils;
|
||||||
using Acacia.ZPush;
|
using Acacia.ZPush;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -16,6 +17,7 @@ namespace Acacia.Stubs
|
|||||||
NSOutlook.Application RawApp { get; } // TODO: remove
|
NSOutlook.Application RawApp { get; } // TODO: remove
|
||||||
|
|
||||||
ZPushWatcher Watcher { get; }
|
ZPushWatcher Watcher { get; }
|
||||||
|
MailEvents MailEvents { get; }
|
||||||
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; }
|
||||||
|
@ -85,6 +85,7 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
public OutlookUI OutlookUI { get { return _thisAddIn.OutlookUI; } }
|
public OutlookUI OutlookUI { get { return _thisAddIn.OutlookUI; } }
|
||||||
|
|
||||||
public ZPushWatcher Watcher { get { return _thisAddIn.Watcher; } }
|
public ZPushWatcher Watcher { get { return _thisAddIn.Watcher; } }
|
||||||
|
public MailEvents MailEvents { get { return _thisAddIn.MailEvents; } }
|
||||||
public IEnumerable<Feature> Features { get { return _thisAddIn.Features; } }
|
public IEnumerable<Feature> Features { get { return _thisAddIn.Features; } }
|
||||||
public IEnumerable<KeyValuePair<string, string>> COMAddIns
|
public IEnumerable<KeyValuePair<string, string>> COMAddIns
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,22 @@ namespace Acacia
|
|||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MailEvents _mailEvents;
|
||||||
|
public MailEvents MailEvents
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_mailEvents == null)
|
||||||
|
{
|
||||||
|
if (GlobalOptions.INSTANCE.HookItemEvents)
|
||||||
|
{
|
||||||
|
_mailEvents = new MailEvents(Instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _mailEvents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Startup / Shutdown
|
#region Startup / Shutdown
|
||||||
|
|
||||||
private void ThisAddIn_Startup(object sender, System.EventArgs args)
|
private void ThisAddIn_Startup(object sender, System.EventArgs args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user