diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
index b02b756..7370ed3 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/AcaciaZPushPlugin.csproj
@@ -297,6 +297,7 @@
+
@@ -309,6 +310,7 @@
+
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs
index d79feb4..691eb2d 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs
@@ -22,6 +22,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -68,8 +69,7 @@ namespace Acacia.Features.SecondaryContacts
public override void Startup()
{
- Watcher.WatchFolder(new FolderRegistrationSecondaryContacts(this),
- OnUnpatchedFolderDiscovered);
+ Watcher.WatchFolder(new FolderRegistrationSecondaryContacts(this), OnUnpatchedFolderDiscovered);
}
private void OnUnpatchedFolderDiscovered(IFolder folder)
@@ -93,7 +93,7 @@ namespace Acacia.Features.SecondaryContacts
// Stage 1
// Sync type
- Logger.Instance.Trace(this, "Setting sync type");
+ Logger.Instance.Trace(this, "Settin7g sync type");
folder.SetProperty(OutlookConstants.PR_EAS_SYNCTYPE, (int)OutlookConstants.SyncType.UserContact);
// Container type
@@ -102,15 +102,42 @@ namespace Acacia.Features.SecondaryContacts
// Make it invisible.
folder.AttrHidden = true;
+ folder.Save();
Logger.Instance.Debug(this, "Patched secondary contacts folder: {0}", strippedName);
- // Register and show a warning, if not already done.
- // Note that patching may be done multiple times.
- if (!_warnedFolders.Contains(folder.EntryID))
- {
- _warnedFolders.Add(folder.EntryID);
+ WarnRestart(folder);
+ }
+ // If _warnedFolders does not contain the folder (and it's hidden), this means Outlook was restarted.
+ else if (!_warnedFolders.Contains(folder.EntryID))
+ {
+ // Stage 2
- if (MessageBox.Show(StringUtil.GetResourceString("SecondaryContactsPatched_Body", strippedName),
+ // Patch the name
+ Logger.Instance.Trace(this, "Patching name");
+ folder.Name = strippedName;
+
+ // Show it
+ folder.AttrHidden = false;
+ Logger.Instance.Debug(this, "Shown secondary contacts folder: {0}", strippedName);
+ }
+ Logger.Instance.Debug(this, "Patching done: {0}: {1}", strippedName, folder.AttrHidden);
+ }
+
+ private DateTime? _lastWarning;
+
+ private void WarnRestart(IFolder folder)
+ {
+ // Register and show a warning, if not already done.
+ // Note that patching may be done multiple times.
+ if (!_warnedFolders.Contains(folder.EntryID))
+ {
+ _warnedFolders.Add(folder.EntryID);
+
+ // TODO: configurable constant for warning time
+ if (_lastWarning == null || DateTime.Now - _lastWarning >= TimeSpan.FromHours(1))
+ {
+ _lastWarning = DateTime.Now;
+ if (MessageBox.Show(StringUtil.GetResourceString("SecondaryContactsPatched_Body", folder.Name),
StringUtil.GetResourceString("SecondaryContactsPatched_Title"),
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning
@@ -120,19 +147,6 @@ namespace Acacia.Features.SecondaryContacts
}
}
}
- // If _warnedFolders does not contain the folder (and it's hidden), this means Outlook was restarted.
- else if (!_warnedFolders.Contains(folder.EntryID))
- {
- // Stage 2
-
- // Patch the name
- Logger.Instance.Trace(this, "Patching name");
- folder.Name = strippedName;
-
- // Show it
- folder.AttrHidden = false;
- Logger.Instance.Debug(this, "Shown secondary contacts folder: {0}", strippedName);
- }
}
}
}
\ No newline at end of file
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/ICommandBars.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/ICommandBars.cs
index bb3f908..ee9f588 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/ICommandBars.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/ICommandBars.cs
@@ -25,6 +25,7 @@ namespace Acacia.Stubs
{
public interface IMSOCommand
{
+ IPicture GetPicture(Size imageSize);
Bitmap GetImage(Size imageSize);
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IFolder.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IFolder.cs
index 7b3848e..911f969 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IFolder.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IFolder.cs
@@ -120,5 +120,9 @@ namespace Acacia.Stubs
get;
set;
}
+
+ void Save();
+
+ void SetCustomIcon(IPicture icon);
}
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IPicture.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IPicture.cs
new file mode 100644
index 0000000..8a9486c
--- /dev/null
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IPicture.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 IPicture : IComWrapper
+ {
+ }
+}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/CommandBarsWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/CommandBarsWrapper.cs
index cae203a..7c7a83f 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/CommandBarsWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/CommandBarsWrapper.cs
@@ -39,6 +39,11 @@ namespace Acacia.Stubs.OutlookWrappers
this._id = id;
}
+ public IPicture GetPicture(Size imageSize)
+ {
+ return _commands._item.GetImageMso(_id, imageSize.Width, imageSize.Height).Wrap();
+ }
+
public Bitmap GetImage(Size imageSize)
{
IPictureDisp pict = _commands._item.GetImageMso(_id, imageSize.Width, imageSize.Height);
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs
index 8b0b159..ff8499f 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs
@@ -24,6 +24,7 @@ using Acacia.Utils;
using Acacia.ZPush;
using NSOutlook = Microsoft.Office.Interop.Outlook;
using Acacia.Native.MAPI;
+using stdole;
namespace Acacia.Stubs.OutlookWrappers
{
@@ -56,6 +57,19 @@ namespace Acacia.Stubs.OutlookWrappers
return new FolderWrapper(CloneComObject());
}
+ public void Save()
+ {
+ IMAPIFolder imapi = _item.MAPIOBJECT as IMAPIFolder;
+ try
+ {
+ imapi.SaveChanges(SaveChangesFlags.FORCE_SAVE);
+ }
+ finally
+ {
+ ComRelease.Release(imapi);
+ }
+ }
+
internal NSOutlook.Folder RawItem { get { return _item; } }
protected override NSOutlook.PropertyAccessor GetPropertyAccessor()
@@ -360,6 +374,11 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
+ public void SetCustomIcon(IPicture icon)
+ {
+ _item.SetCustomIcon(((PictureWrapper)icon).RawItem as StdPicture);
+ }
+
#endregion
public ItemType DefaultItemType
@@ -395,7 +414,8 @@ namespace Acacia.Stubs.OutlookWrappers
set
{
-
+ // TODO
+ throw new NotImplementedException();
}
}
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs
index 3bddb65..3aae7e4 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/Mapping.cs
@@ -87,6 +87,15 @@ namespace Acacia.Stubs.OutlookWrappers
return wrapped;
}
+ public static IPicture Wrap(stdole.IPictureDisp obj, bool mustRelease = true)
+ {
+ if (obj == null)
+ return null;
+ PictureWrapper wrapped = new PictureWrapper(obj);
+ wrapped.MustRelease = mustRelease;
+ return wrapped;
+ }
+
// TODO: extension methods for this
public static IStore Wrap(NSOutlook.Store obj, bool mustRelease = true)
{
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/PictureWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/PictureWrapper.cs
new file mode 100644
index 0000000..2c180ec
--- /dev/null
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/PictureWrapper.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Acacia.Stubs.OutlookWrappers
+{
+ class PictureWrapper : ComWrapper, IPicture
+ {
+ internal PictureWrapper(stdole.IPictureDisp item) : base(item)
+ {
+ }
+
+ internal stdole.IPictureDisp RawItem { get { return _item; } }
+ }
+}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/Wrappers.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/Wrappers.cs
index db4a234..bc83232 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/Wrappers.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/Wrappers.cs
@@ -62,5 +62,10 @@ namespace Acacia.Stubs
{
return Mapping.WrapOrDefault(o, mustRelease);
}
+
+ public static IPicture Wrap(this stdole.IPictureDisp picture)
+ {
+ return Mapping.Wrap(picture);
+ }
}
}
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushFolder.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushFolder.cs
index 5c22348..77f20c5 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushFolder.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushFolder.cs
@@ -157,7 +157,7 @@ namespace Acacia.ZPush
// Hence, fetch all the remaining folder ids, and remove any folder that no longer exists.
// TODO: move this logic into IFolders?
HashSet remaining = new HashSet();
- foreach (IFolder child in _folder.SubFolders)
+ foreach (IFolder child in _folder.SubFolders.DisposeEnum())
{
try
{