diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
index 702b8e4..ed0c59b 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
@@ -280,9 +280,13 @@
+
+
+
+
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
index 28b23c6..aadb251 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
@@ -281,23 +281,25 @@ namespace Acacia.Features.GAB
///
private void DoSuppressEvent(IItem item, ref bool cancel)
{
+ // TODO: Find and close the inspector
/*if (item != null)
{
- foreach (Inspector inspector in App.Inspectors)
+ foreach (Inspector inspector in ThisAddIn.Instance.Inspectors)
{
if (item.EntryId == inspector.CurrentItem.EntryID)
{
break;
}
}
- }
+ }*/
+
+ // Show message and cancel event
MessageBox.Show(StringUtil.GetResourceString("GABEvent_Body"),
StringUtil.GetResourceString("GABEvent_Title"),
MessageBoxButtons.OK,
MessageBoxIcon.Warning
);
- cancel = true;*/
- // TODO
+ cancel = true;
}
#endregion
@@ -436,9 +438,12 @@ namespace Acacia.Features.GAB
GABInfo gabInfo = GABInfo.Get(gab, domainName);
gabInfo.Store(gab);
- // Hook BeforeMove event to prevent modifications
- // TODO: use ZPushWatcher for this?
- gab.BeforeItemMove += SuppressMoveEventHandler;
+ if (SuppressModifications)
+ {
+ // Hook BeforeMove event to prevent modifications
+ // TODO: use ZPushWatcher for this?
+ gab.BeforeItemMove += SuppressMoveEventHandler;
+ }
return gab;
}
@@ -446,8 +451,11 @@ namespace Acacia.Features.GAB
private void DisposeGABContacts(IAddressBook gab)
{
- // Unhook the event to prevent the gab lingering in memory
- gab.BeforeItemMove -= SuppressMoveEventHandler;
+ if (SuppressModifications)
+ {
+ // Unhook the event to prevent the gab lingering in memory
+ gab.BeforeItemMove -= SuppressMoveEventHandler;
+ }
}
public static GABInfo GetGABContactsFolderInfo(IFolder folder)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SendAs/FeatureSendAs.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SendAs/FeatureSendAs.cs
index 25c8678..a8d6d9c 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SendAs/FeatureSendAs.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SendAs/FeatureSendAs.cs
@@ -90,18 +90,21 @@ namespace Acacia.Features.SendAs
{
Logger.Instance.Trace(this, "Checking, Shared folder owner: {0}", shared.Store.UserName);
// It's a shared folder, use the owner as the sender if possible
- // TODO: make a wrapper for this
- // TODO: remove RawApp access
- var recip = ThisAddIn.Instance.RawApp.Session.CreateRecipient(shared.Store.UserName);
- Logger.Instance.Trace(this, "Checking, Shared folder owner recipient: {0}", recip.Name);
- if (recip != null && recip.Resolve())
+ using (IRecipient recip = ThisAddIn.Instance.ResolveRecipient(shared.Store.UserName))
{
- Logger.Instance.Trace(this, "Sending as: {0}", recip.AddressEntry.Address);
- response.SetSender(recip.AddressEntry);
- }
- else
- {
- Logger.Instance.Trace(this, "Unable to resolve sender");
+ Logger.Instance.Trace(this, "Checking, Shared folder owner recipient: {0}", recip.Name);
+ if (recip != null && recip.IsResolved)
+ {
+ Logger.Instance.Trace(this, "Sending as: {0}", recip.Address);
+ using (IAddressEntry address = recip.GetAddressEntry())
+ {
+ response.SetSender(address);
+ }
+ }
+ else
+ {
+ Logger.Instance.Trace(this, "Unable to resolve sender");
+ }
}
}
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs
index 642ebce..ed384be 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddIn.cs
@@ -34,6 +34,9 @@ namespace Acacia.Stubs
#endregion
+ #region Miscellaneous methods
+ // TODO: clean this up
+
///
/// Sends and receives all accounts.
///
@@ -51,5 +54,9 @@ namespace Acacia.Stubs
FeatureType GetFeature()
where FeatureType : Feature;
+
+ IRecipient ResolveRecipient(string name);
+
+ #endregion
}
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddressEntry.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddressEntry.cs
new file mode 100644
index 0000000..c27a0dc
--- /dev/null
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IAddressEntry.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Acacia.Stubs
+{
+ public interface IAddressEntry : IComWrapper
+ {
+ }
+}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IMailItem.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IMailItem.cs
index 5fff5dc..5f775fe 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IMailItem.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IMailItem.cs
@@ -33,7 +33,10 @@ namespace Acacia.Stubs
string SenderEmailAddress { get; }
string SenderName { get; }
- // TODO: make a wrapper for this
- void SetSender(Microsoft.Office.Interop.Outlook.AddressEntry addressEntry);
+ ///
+ /// Sets the sender.
+ ///
+ /// The address. The caller is responsible for disposing.
+ void SetSender(IAddressEntry addressEntry);
}
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IRecipient.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IRecipient.cs
new file mode 100644
index 0000000..907de91
--- /dev/null
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IRecipient.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Acacia.Stubs
+{
+ public interface IRecipient : IComWrapper
+ {
+ bool IsResolved { get; }
+
+ string Name { get; }
+ string Address { get; }
+
+ ///
+ /// Returns the address entry. The caller is responsible for disposing it.
+ ///
+ IAddressEntry GetAddressEntry();
+ }
+}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs
index 290617f..b2cbe70 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs
@@ -190,5 +190,19 @@ namespace Acacia.Stubs.OutlookWrappers
#endregion
+
+ public IRecipient ResolveRecipient(string name)
+ {
+ using (ComRelease com = new ComRelease())
+ {
+ NSOutlook.NameSpace session = com.Add(_app.Session);
+ NSOutlook.Recipient recipient = session.CreateRecipient(name);
+ if (recipient == null)
+ return null;
+ com.Add(recipient);
+ recipient.Resolve();
+ return Mapping.Wrap(com.Remove(recipient));
+ }
+ }
}
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddressEntryWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddressEntryWrapper.cs
new file mode 100644
index 0000000..0212065
--- /dev/null
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddressEntryWrapper.cs
@@ -0,0 +1,28 @@
+using Acacia.Utils;
+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 AddressEntryWrapper : ComWrapper, IAddressEntry
+ {
+ private NSOutlook.AddressEntry _item;
+
+ internal AddressEntryWrapper(NSOutlook.AddressEntry item)
+ {
+ this._item = item;
+ }
+
+ internal NSOutlook.AddressEntry RawItem { get { return _item; } }
+
+ protected override void DoRelease()
+ {
+ ComRelease.Release(_item);
+ _item = null;
+ }
+ }
+}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs
index 7771581..76753eb 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs
@@ -42,31 +42,27 @@ namespace Acacia.Stubs.OutlookWrappers
}
set
{
- using (ComRelease com = new ComRelease())
- {
- string displayName = DLName + " (" + value + ")";
- byte[] oneOffId = CreateOneOffMemberId(DLName, "SMTP", value);
+ string displayName = DLName + " (" + value + ")";
+ byte[] oneOffId = CreateOneOffMemberId(DLName, "SMTP", value);
- NSOutlook.PropertyAccessor props = com.Add(_item.PropertyAccessor);
- props.SetProperties(
- new string[]
- {
- OutlookConstants.PR_EMAIL1DISPLAYNAME,
- OutlookConstants.PR_EMAIL1EMAILADDRESS,
- OutlookConstants.PR_EMAIL1ADDRESSTYPE,
- OutlookConstants.PR_EMAIL1ORIGINALDISPLAYNAME,
- OutlookConstants.PR_EMAIL1ORIGINALENTRYID
- },
- new object[]
- {
- DLName,
- value,
- "SMTP",
- value,
- oneOffId
- }
- );
- }
+ SetProperties(
+ new string[]
+ {
+ OutlookConstants.PR_EMAIL1DISPLAYNAME,
+ OutlookConstants.PR_EMAIL1EMAILADDRESS,
+ OutlookConstants.PR_EMAIL1ADDRESSTYPE,
+ OutlookConstants.PR_EMAIL1ORIGINALDISPLAYNAME,
+ OutlookConstants.PR_EMAIL1ORIGINALENTRYID
+ },
+ new object[]
+ {
+ DLName,
+ value,
+ "SMTP",
+ value,
+ oneOffId
+ }
+ );
}
}
@@ -95,12 +91,15 @@ namespace Acacia.Stubs.OutlookWrappers
private void AddContactMember(IContactItem member)
{
string email = member.Email1Address;
- // TODO: remove RawApp, Recipient wrapper
- NSOutlook.Recipient recipient = ThisAddIn.Instance.RawApp.Session.CreateRecipient(email);
- if (recipient.Resolve())
- _item.AddMember(recipient);
- else
- Logger.Instance.Warning(this, "Unable to resolve recipient: {0}", email);
+ using (IRecipient recipient = ThisAddIn.Instance.ResolveRecipient(email))
+ {
+ if (recipient.IsResolved)
+ {
+ _item.AddMember(((RecipientWrapper)recipient).RawItem);
+ }
+ else
+ Logger.Instance.Warning(this, "Unable to resolve recipient: {0}", email);
+ }
}
private void AddDistributionListMember(IDistributionList member)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs
index be57f96..b9753c1 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs
@@ -81,9 +81,9 @@ namespace Acacia.Stubs.OutlookWrappers
}
- public void SetSender(NSOutlook.AddressEntry addressEntry)
+ public void SetSender(IAddressEntry addressEntry)
{
- _item.Sender = addressEntry;
+ _item.Sender = ((AddressEntryWrapper)addressEntry).RawItem;
}
#endregion
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs
index 019e5cf..2dabe2b 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs
@@ -78,6 +78,13 @@ namespace Acacia.Stubs.OutlookWrappers
return (Type)Wrap(o, mustRelease);
}
+ public static IRecipient Wrap(NSOutlook.Recipient r, bool mustRelease = true)
+ {
+ RecipientWrapper wrapped = new RecipientWrapper(r);
+ wrapped.MustRelease = mustRelease;
+ return wrapped;
+ }
+
// TODO: are these not the same now? Differ only on wrong type?
public static Type WrapOrDefault(object o, bool mustRelease = true)
where Type : IBase
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs
index e3ebaa2..79e38e1 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs
@@ -24,7 +24,7 @@ using NSOutlook = Microsoft.Office.Interop.Outlook;
namespace Acacia.Stubs.OutlookWrappers
{
- public class NoteItemWrapper : OutlookItemWrapper, INoteItem
+ class NoteItemWrapper : OutlookItemWrapper, INoteItem
{
internal NoteItemWrapper(NSOutlook.NoteItem item)
:
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/RecipientWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/RecipientWrapper.cs
new file mode 100644
index 0000000..673e1ce
--- /dev/null
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/RecipientWrapper.cs
@@ -0,0 +1,58 @@
+using Acacia.Utils;
+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 RecipientWrapper : ComWrapper, IRecipient
+ {
+ private NSOutlook.Recipient _item;
+
+ internal RecipientWrapper(NSOutlook.Recipient item)
+ {
+ this._item = item;
+ }
+
+ internal NSOutlook.Recipient RawItem { get { return _item; } }
+
+ protected override void DoRelease()
+ {
+ ComRelease.Release(_item);
+ _item = null;
+ }
+
+ public bool IsResolved
+ {
+ get
+ {
+ return _item.Resolved;
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return _item.Name;
+ }
+ }
+
+ public string Address
+ {
+ get
+ {
+ return _item.Address;
+ // TODO:? return _item.AddressEntry.Address
+ }
+ }
+
+ public IAddressEntry GetAddressEntry()
+ {
+ return new AddressEntryWrapper(_item.AddressEntry);
+ }
+ }
+}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs
index 833f7a1..9f6e7ac 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs
@@ -25,7 +25,7 @@ using NSOutlook = Microsoft.Office.Interop.Outlook;
namespace Acacia.Stubs.OutlookWrappers
{
- public class TaskItemWrapper : OutlookItemWrapper, ITaskItem
+ class TaskItemWrapper : OutlookItemWrapper, ITaskItem
{
internal TaskItemWrapper(NSOutlook.TaskItem item)
:
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ComRelease.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ComRelease.cs
index 19c260d..cd24376 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ComRelease.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ComRelease.cs
@@ -34,6 +34,12 @@ namespace Acacia.Utils
return t;
}
+ public Type Remove(Type t)
+ {
+ objects.Remove(t);
+ return t;
+ }
+
public void Dispose()
{
foreach (object o in objects)