[KOE-119] Added explicit check for deleted folders when warning about secondary contacts.

This commit is contained in:
Patrick Simpson 2017-06-07 10:38:36 +02:00
parent 747de0d6c1
commit 158be43e11
12 changed files with 116 additions and 277 deletions

View File

@ -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

View File

@ -40,6 +40,11 @@ namespace Acacia.Stubs
IFolder Parent { get; }
string ParentEntryID { get; }
/// <summary>
/// Checks if the object is in the deleted items folder.
/// </summary>
bool IsDeleted { get; }
/// <summary>
/// Returns the store. The owner is responsible for disposing.
/// </summary>

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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();
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -29,7 +29,7 @@ namespace Acacia.Stubs.OutlookWrappers
/// <summary>
/// Helper for Outlook wrapper implementations
/// </summary>
abstract class OutlookWrapper<ItemType> : ComWrapper<ItemType>
abstract class OutlookWrapper<ItemType> : ComWrapper<ItemType>, 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();
}
}

View File

@ -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
}

View File

@ -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
}