From 158be43e11a80ab4da2c71e1284815e642e20263 Mon Sep 17 00:00:00 2001 From: Patrick Simpson Date: Wed, 7 Jun 2017 10:38:36 +0200 Subject: [PATCH] [KOE-119] Added explicit check for deleted folders when warning about secondary contacts. --- .../FeatureSecondaryContacts.cs | 8 ++- .../AcaciaZPushPlugin/Stubs/IBase.cs | 5 ++ .../OutlookWrappers/AppointmentItemWrapper.cs | 36 ++--------- .../OutlookWrappers/ContactItemWrapper.cs | 36 ++--------- .../DistributionListWrapper.cs | 36 ++--------- .../Stubs/OutlookWrappers/FolderWrapper.cs | 31 ++-------- .../Stubs/OutlookWrappers/MailItemWrapper.cs | 36 ++--------- .../OutlookWrappers/MeetingItemWrapper.cs | 36 ++--------- .../Stubs/OutlookWrappers/NoteItemWrapper.cs | 36 ++--------- .../Stubs/OutlookWrappers/OutlookWrapper.cs | 61 ++++++++++++++++++- .../OutlookWrappers/StorageItemWrapper.cs | 36 ++--------- .../Stubs/OutlookWrappers/TaskItemWrapper.cs | 36 ++--------- 12 files changed, 116 insertions(+), 277 deletions(-) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs index 9598bb4..82ef325 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SecondaryContacts/FeatureSecondaryContacts.cs @@ -66,7 +66,11 @@ namespace Acacia.Features.SecondaryContacts // Check the hidden suffix if (!folder.Name.EndsWith(SUFFIX_CONTACTS)) return false; - + + // Deleted contacts folders won't sync anyway + if (folder.IsDeleted) + return false; + return true; } } @@ -104,7 +108,7 @@ namespace Acacia.Features.SecondaryContacts // Stage 1 // Sync type - Logger.Instance.Trace(this, "Settin7g sync type"); + Logger.Instance.Trace(this, "Setting sync type"); folder.SetProperty(OutlookConstants.PR_EAS_SYNCTYPE, (int)OutlookConstants.SyncType.UserContact); // Container type diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IBase.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IBase.cs index 3a9aeee..d02c6a6 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IBase.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/IBase.cs @@ -40,6 +40,11 @@ namespace Acacia.Stubs IFolder Parent { get; } string ParentEntryID { get; } + /// + /// Checks if the object is in the deleted items folder. + /// + bool IsDeleted { get; } + /// /// Returns the store. The owner is responsible for disposing. /// diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AppointmentItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AppointmentItemWrapper.cs index 1ae694a..a866794 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AppointmentItemWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AppointmentItemWrapper.cs @@ -98,9 +98,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -109,7 +109,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -120,7 +120,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -129,33 +129,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/ContactItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/ContactItemWrapper.cs index b7cc7aa..a22816d 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/ContactItemWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/ContactItemWrapper.cs @@ -218,9 +218,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -229,7 +229,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -241,7 +241,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -250,33 +250,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs index 5cb106c..5cb3f3e 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/DistributionListWrapper.cs @@ -234,9 +234,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -245,7 +245,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -257,7 +257,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -266,33 +266,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs index f7b3e6a..2c5587b 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/FolderWrapper.cs @@ -79,7 +79,7 @@ namespace Acacia.Stubs.OutlookWrappers public string FullFolderPath { get { return _item.FullFolderPath; } } - public IFolder Parent + override public IFolder Parent { get { @@ -88,7 +88,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -136,30 +136,9 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IStore GetStore() { return Mapping.Wrap(_item.Store); } - - public string StoreID - { - get - { - using (IStore store = GetStore()) - { - return store.StoreID; - } - } - } - public string StoreDisplayName - { - get - { - using (IStore store = GetStore()) - { - return store.DisplayName; - } - } - } + override public IStore GetStore() { return Mapping.Wrap(_item.Store); } public ItemType ItemType { get { return (ItemType)(int)_item.DefaultItemType; } } @@ -310,7 +289,7 @@ namespace Acacia.Stubs.OutlookWrappers #endregion - public void Delete() + override public void Delete() { _item.Delete(); } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs index 02e126f..aab1323 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MailItemWrapper.cs @@ -162,9 +162,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -173,7 +173,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -185,7 +185,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -194,33 +194,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MeetingItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MeetingItemWrapper.cs index 334385e..3c3adbc 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MeetingItemWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/MeetingItemWrapper.cs @@ -99,9 +99,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -110,7 +110,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -122,7 +122,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -131,33 +131,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs index 35f7212..577d0f1 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/NoteItemWrapper.cs @@ -74,9 +74,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -85,7 +85,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -97,7 +97,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -106,33 +106,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/OutlookWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/OutlookWrapper.cs index 0618d79..b3b0a2d 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/OutlookWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/OutlookWrapper.cs @@ -29,7 +29,7 @@ namespace Acacia.Stubs.OutlookWrappers /// /// Helper for Outlook wrapper implementations /// - abstract class OutlookWrapper : ComWrapper + abstract class OutlookWrapper : ComWrapper, IBase { #region Construction / Destruction @@ -80,6 +80,63 @@ namespace Acacia.Stubs.OutlookWrappers #endregion + #region IBase implementation + + public bool IsDeleted + { + get + { + string deletedEntryId; + using (IStore store = GetStore()) + { + using (IFolder deleted = store.GetDefaultFolder(DefaultFolder.DeletedItems)) + deletedEntryId = deleted.EntryID; + } + + IFolder current = Parent; + while (current != null) + { + if (current.EntryID == deletedEntryId) + { + current.Dispose(); + return true; + } + IFolder parent = current.Parent; + current.Dispose(); + current = parent; + } + return false; + } + } + + public abstract string EntryID { get; } + public abstract IFolder Parent { get; } + public abstract string ParentEntryID { get; } + + virtual public string StoreID + { + get + { + using (IStore store = GetStore()) + { + return store.StoreID; + } + } + } + + virtual public string StoreDisplayName + { + get + { + using (IStore store = GetStore()) + { + return store.DisplayName; + } + } + } + + #endregion + #region Properties public string[] AttrCategories @@ -140,5 +197,7 @@ namespace Acacia.Stubs.OutlookWrappers #endregion public override abstract string ToString(); + public abstract IStore GetStore(); + public abstract void Delete(); } } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StorageItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StorageItemWrapper.cs index db349d6..b183f1c 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StorageItemWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/StorageItemWrapper.cs @@ -72,9 +72,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -83,7 +83,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -95,7 +95,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -104,33 +104,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs index 5e87cb3..3448c82 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/TaskItemWrapper.cs @@ -72,9 +72,9 @@ namespace Acacia.Stubs.OutlookWrappers #region IBase implementation - public string EntryID { get { return _item.EntryID; } } + override public string EntryID { get { return _item.EntryID; } } - public IFolder Parent + override public IFolder Parent { get { @@ -83,7 +83,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string ParentEntryID + override public string ParentEntryID { get { @@ -95,7 +95,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public IStore GetStore() + override public IStore GetStore() { using (ComRelease com = new ComRelease()) { @@ -104,33 +104,7 @@ namespace Acacia.Stubs.OutlookWrappers } } - public string StoreID - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public string StoreDisplayName - { - get - { - using (ComRelease com = new ComRelease()) - { - NSOutlook.Folder parent = com.Add(_item.Parent); - NSOutlook.Store store = com.Add(parent?.Store); - return store.StoreID; - } - } - } - - public void Delete() { _item.Delete(); } + override public void Delete() { _item.Delete(); } #endregion }