diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
index c2358c7..0fe5e05 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
@@ -74,7 +74,8 @@ namespace Acacia.Features.GAB
if (SuppressModifications && MailEvents != null)
{
MailEvents.BeforeDelete += SuppressEventHandler_Delete;
- MailEvents.Write += SuppressEventHandler_Modify;
+ MailEvents.PropertyChange += SuppressEventHandler_PropertyChange;
+ MailEvents.Write += SuppressEventHandler_Write;
}
Watcher.AccountDiscovered += AccountDiscovered;
Watcher.AccountRemoved += AccountRemoved;
@@ -247,9 +248,27 @@ namespace Acacia.Features.GAB
SuppressEventHandler(item, false, ref cancel);
}
- private void SuppressEventHandler_Modify(IItem item, ref bool cancel)
+ ///
+ /// When copying a contact from the GAB to a local folder, Outlook raises the Write event on
+ /// the original. To detect this, we set this id on every property change (which is signalled before
+ /// write), and only suppress if anything has actually changed. If we suppress, the flag is cleared again.
+ ///
+ private string _propertyChangeId;
+
+ private void SuppressEventHandler_PropertyChange(IItem item, string propertyName)
{
- SuppressEventHandler(item, true, ref cancel);
+ if (_propertyChangeId == item.EntryID)
+ return;
+ _propertyChangeId = item.EntryID;
+ }
+
+ private void SuppressEventHandler_Write(IItem item, ref bool cancel)
+ {
+ if (_propertyChangeId == item.EntryID)
+ {
+ SuppressEventHandler(item, true, ref cancel);
+ _propertyChangeId = null;
+ }
}
private void SuppressEventHandler(IItem item, bool findInspector, ref bool cancel)
@@ -301,7 +320,10 @@ namespace Acacia.Features.GAB
}*/
// Show message and cancel event
- MessageBox.Show(StringUtil.GetResourceString("GABEvent_Body"),
+ // TODO: show on active inspector if used
+ // [KOE-108] If the window is not specified as parent, it sometimes doesn't show
+ var res = MessageBox.Show(ThisAddIn.Instance.Window,
+ StringUtil.GetResourceString("GABEvent_Body"),
StringUtil.GetResourceString("GABEvent_Title"),
MessageBoxButtons.OK,
MessageBoxIcon.Warning
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs
index ab6daca..1a2a065 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs
@@ -231,6 +231,10 @@ namespace Acacia.Stubs.OutlookWrappers
#region Window handle
+ ///
+ /// Simple IWin32Window wrapper for a native handle. NativeWindow sometimes refuses to handle
+ /// these (FromHandle returns null), so use a simple wrapper.
+ ///
private class WindowHandle : IWin32Window
{
private IntPtr hWnd;
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs
index 543ef0a..8e7d799 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs
@@ -38,6 +38,7 @@ namespace Acacia.Utils
public delegate void MailEventHandler(IMailItem mail);
public delegate void MailResponseEventHandler(IMailItem mail, IMailItem response);
public delegate void ItemEventHandler(IItem item);
+ public delegate void PropertyChangeEventHandler(IItem item, string propertyName);
public delegate void CancellableItemEventHandler(IItem item, ref bool cancel);
public delegate void CancellableMailItemEventHandler(IMailItem item, ref bool cancel);
@@ -119,6 +120,22 @@ namespace Acacia.Utils
}
}
+ public event PropertyChangeEventHandler PropertyChange;
+ private void OnPropertyChange(IItem item, string propertyName)
+ {
+ try
+ {
+ if (PropertyChange != null && item != null)
+ {
+ PropertyChange(item, propertyName);
+ }
+ }
+ catch (System.Exception e)
+ {
+ Logger.Instance.Error(this, "OnPropertyChange: {0}", e);
+ }
+ }
+
public event CancellableItemEventHandler BeforeDelete;
private void OnBeforeDelete(IItem item, ref bool cancel)
{
@@ -369,6 +386,7 @@ namespace Acacia.Utils
events.BeforeDelete += HandleBeforeDelete;
events.Forward += HandleForward;
+ events.PropertyChange += HandlePropertyChange;
events.Read += HandleRead;
events.Reply += HandleReply;
events.ReplyAll += HandleReplyAll;
@@ -379,6 +397,7 @@ namespace Acacia.Utils
{
events.BeforeDelete -= HandleBeforeDelete;
events.Forward -= HandleForward;
+ events.PropertyChange -= HandlePropertyChange;
events.Read -= HandleRead;
events.Reply -= HandleReply;
events.ReplyAll -= HandleReplyAll;
@@ -400,8 +419,14 @@ namespace Acacia.Utils
_events.OnForward(_item as IMailItem, wrapped as IMailItem);
}
+ private void HandlePropertyChange(string name)
+ {
+ _events.OnPropertyChange(_item, name);
+ }
+
private void HandleRead()
{
+ // TODO: should this not be simply an IItem?
_events.OnRead(_item as IMailItem);
}