diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Feature.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Feature.cs
index abd39a4..2de436f 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Feature.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/Feature.cs
@@ -194,7 +194,7 @@ namespace Acacia.Features
#region Event helpers
- protected static MailEvents MailEvents
+ public static MailEvents MailEvents
{
get
{
@@ -202,7 +202,7 @@ namespace Acacia.Features
}
}
- protected ZPushWatcher Watcher
+ public ZPushWatcher Watcher
{
get
{
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
index ef8de7b..a1ca40e 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/GAB/FeatureGAB.cs
@@ -71,15 +71,24 @@ namespace Acacia.Features.GAB
public override void Startup()
{
- if (SuppressModifications && MailEvents != null)
+ SetupModificationSuppression();
+ Watcher.AccountDiscovered += AccountDiscovered;
+ Watcher.AccountRemoved += AccountRemoved;
+ Watcher.AccountsScanned += AccountsScanned;
+ }
+
+ private void SetupModificationSuppression()
+ {
+ if (MailEvents == null)
+ return;
+
+ // GAB modification suppression
+ if (SuppressModifications)
{
MailEvents.BeforeDelete += SuppressEventHandler_Delete;
MailEvents.PropertyChange += SuppressEventHandler_PropertyChange;
MailEvents.Write += SuppressEventHandler_Write;
}
- Watcher.AccountDiscovered += AccountDiscovered;
- Watcher.AccountRemoved += AccountRemoved;
- Watcher.AccountsScanned += AccountsScanned;
}
#region Settings
@@ -367,7 +376,7 @@ namespace Acacia.Features.GAB
// Delete any contacts folders in the local store
if (DeleteExistingFolder)
{
- using (IStore store = ZPushLocalStore.GetInstance(ThisAddIn.Instance))
+ using (IStore store = ZPushLocalStore.GetInstance(ThisAddIn.Instance, this))
{
if (store != null)
{
@@ -471,7 +480,7 @@ namespace Acacia.Features.GAB
_store.Dispose();
_store = null;
}
- _store = ZPushLocalStore.GetInstance(ThisAddIn.Instance);
+ _store = ZPushLocalStore.GetInstance(ThisAddIn.Instance, this);
if (_store == null)
return null;
@@ -614,7 +623,7 @@ namespace Acacia.Features.GAB
_store.Dispose();
_store = null;
}
- _store = ZPushLocalStore.GetInstance(ThisAddIn.Instance);
+ _store = ZPushLocalStore.GetInstance(ThisAddIn.Instance, this);
if (_store == null)
return;
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs
index 6146aa8..7b888de 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.Designer.cs
@@ -205,6 +205,24 @@ namespace Acacia.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Storing items in Kopano Folders is not supported..
+ ///
+ internal static string LocalStore_Move_Body {
+ get {
+ return ResourceManager.GetString("LocalStore_Move_Body", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Kopano Folders.
+ ///
+ internal static string LocalStore_Move_Title {
+ get {
+ return ResourceManager.GetString("LocalStore_Move_Title", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to There are unsaved changes. Do you really want to to discard these?.
///
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx
index 838b56d..2b256b5 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Properties/Resources.resx
@@ -539,4 +539,10 @@ Please contact your system administrator for any required changes.
Unable to determine the send-as email address for the existing shared folder {0}. Send-as will only work if you specify the email address manually. Would you like to open the Shared Folders dialog?
+
+ Storing items in Kopano Folders is not supported.
+
+
+ Kopano Folders
+
\ No newline at end of file
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushLocalStore.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushLocalStore.cs
index 7465625..078254a 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushLocalStore.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushLocalStore.cs
@@ -23,6 +23,9 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Acacia.Features.GAB;
+using Acacia.Features;
+using System.Windows.Forms;
namespace Acacia.ZPush
{
@@ -35,7 +38,7 @@ namespace Acacia.ZPush
/// Returns or creates the local store.
///
/// The store, or null on error. If a store is returned, the caller is responsible for disposing.
- public static IStore GetInstance(IAddIn addIn)
+ public static IStore GetInstance(IAddIn addIn, Feature feature)
{
IStore store = OpenOrCreateInstance(addIn);
if (store == null)
@@ -44,6 +47,7 @@ namespace Acacia.ZPush
try
{
HideAllFolders(store);
+ SetupChangeSuppression(store, feature);
return store;
}
catch(Exception e)
@@ -106,6 +110,60 @@ namespace Acacia.ZPush
}
}
+ private static readonly Dictionary _suppressors = new Dictionary();
+
+ private static void SetupChangeSuppression(IStore localStore, Feature feature)
+ {
+ string localStoreID = localStore.StoreID;
+ if (!_suppressors.ContainsKey(localStoreID))
+ {
+ _suppressors.Add(localStoreID, new Suppressor(localStoreID, feature));
+ }
+ }
+
+ private class Suppressor
+ {
+ private readonly string _localStoreID;
+
+ public Suppressor(string localStoreID, Feature feature)
+ {
+ this._localStoreID = localStoreID;
+
+ feature.Watcher.WatchFolder(new FolderRegistrationAny(feature),
+ (folder) =>
+ {
+ folder.BeforeFolderMove += Folder_BeforeFolderMove;
+ folder.BeforeItemMove += Folder_BeforeItemMove;
+ });
+
+ }
+
+ private void Folder_BeforeItemMove(IFolder src, IItem item, IFolder moveTo, ref bool cancel)
+ {
+ SuppressCore(src, item, moveTo, ref cancel);
+ }
+
+ private void Folder_BeforeFolderMove(IFolder src, IFolder moveTo, ref bool cancel)
+ {
+ SuppressCore(src, null, moveTo, ref cancel);
+ }
+
+ private void SuppressCore(IFolder src, IItem item, IFolder moveTo, ref bool cancel)
+ {
+ if (moveTo.StoreID == _localStoreID)
+ {
+ Logger.Instance.Trace(this, "Move into Kopano Folders: {0} - {1}: {2}", src.Name, src.EntryID, item?.EntryID);
+ cancel = true;
+ MessageBox.Show(ThisAddIn.Instance.Window,
+ Properties.Resources.LocalStore_Move_Body,
+ Properties.Resources.LocalStore_Move_Title,
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning
+ );
+ }
+ }
+ }
+
private static IStore FindInstance(IAddIn addIn, string prefix)
{
foreach (IStore store in addIn.Stores)
@@ -122,16 +180,14 @@ namespace Acacia.ZPush
}
return null;
}
-
- private static bool IsCustomFolder(IFolder folder)
- {
- return Features.GAB.FeatureGAB.IsGABContactsFolder(folder, null);
- }
-
+
private static void HideAllFolders(IStore store)
{
if (GlobalOptions.INSTANCE.LocalFolders_Hide)
{
+ HashSet hideIds = new HashSet();
+ hideIds.Add(store.GetDefaultFolderId(DefaultFolder.DeletedItems));
+
// Hide the folders that are not custom folders
using (IFolder root = store.GetRootFolder())
{
@@ -139,7 +195,7 @@ namespace Acacia.ZPush
{
using (sub)
{
- sub.AttrHidden = !IsCustomFolder(sub);
+ sub.AttrHidden = hideIds.Contains(sub.EntryID);
}
}
}