1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-132] Added test to prevent crash when sending email through other applications.

This commit is contained in:
Patrick Simpson 2017-09-06 15:17:45 +03:00
parent d9cd9e4521
commit 6afaa7aeba
14 changed files with 68 additions and 195 deletions

View File

@ -44,7 +44,7 @@ namespace Acacia.Features.BCC
// Check we're in the SentMail folder
using (IFolder folder = mail.Parent)
{
if (_folderRegistration.IsApplicable(folder))
if (folder != null && _folderRegistration.IsApplicable(folder))
CheckBCC(mail);
}
};

View File

@ -57,6 +57,9 @@ namespace Acacia.Features.SecondaryContacts
public override bool IsApplicable(IFolder folder)
{
if (folder == null)
return false;
// Check the sync type.
// Also allow again if the sync type is user contact, it may not have been fully patched.
if (FolderUtils.GetFolderSyncType(folder) != OutlookConstants.SyncType.Unknown &&

View File

@ -89,6 +89,9 @@ namespace Acacia
public const string PR_CONTAINER_CLASS = PROP + "3613" + PT_UNICODE;
public const string PR_ENTRYID = PROP + "0FFF" + PT_BINARY;
public const string PR_PARENT_ENTRYID = PROP + "0E09" + PT_BINARY;
#endregion
#region Email specific

View File

@ -105,7 +105,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -114,26 +114,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (IBase parent = Mapping.Wrap<IBase>(_item.Parent))
{
return parent.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -220,7 +220,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -229,27 +229,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -236,7 +236,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -245,27 +245,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -79,7 +79,7 @@ namespace Acacia.Stubs.OutlookWrappers
public string FullFolderPath { get { return _item.FullFolderPath; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -87,19 +87,7 @@ namespace Acacia.Stubs.OutlookWrappers
return Mapping.Wrap<IFolder>(_item.Parent as NSOutlook.Folder);
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
/// <summary>
/// Checks if the folder is at the specified depth. The root folder is at depth 0, its children at depth 1, etc.
/// This function exists because sometimes it's need to determine if a folder is at a specific depth; using this

View File

@ -164,7 +164,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -173,27 +173,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -101,7 +101,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -110,27 +110,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -76,7 +76,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -85,27 +85,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -82,9 +82,45 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
public abstract string EntryID { get; }
public abstract IFolder Parent { get; }
public abstract string ParentEntryID { get; }
abstract public string EntryID
{
get;
}
public IFolder Parent
{
get
{
if (!CanAccessParent)
return null;
return ParentUnchecked;
}
}
protected abstract IFolder ParentUnchecked { get; }
private bool CanAccessParent
{
get
{
// [KOE-132]: Somehow when sending mail through other applications, accessing parent
// causes an access violation on Outlook 2013. I have been unable to fully determine
// the exact cause, but the entry id seems to be null and the parent entry id set in
// this case. So just avoid that.
if (GetProperty(OutlookConstants.PR_ENTRYID) == null && GetProperty(OutlookConstants.PR_PARENT_ENTRYID) != null)
return false;
return true;
}
}
public string ParentEntryID
{
get
{
return StringUtil.BytesToHex((byte[])GetProperty(OutlookConstants.PR_PARENT_ENTRYID));
}
}
virtual public string StoreID
{
@ -190,10 +226,18 @@ namespace Acacia.Stubs.OutlookWrappers
#endregion
virtual public IStore GetStore()
{
using (IFolder parent = Parent)
{
return parent?.GetStore();
}
}
public override abstract string ToString();
public abstract IStore GetStore();
public abstract void Delete();
override public string DebugContext
{
get

View File

@ -74,7 +74,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -83,27 +83,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -74,7 +74,7 @@ namespace Acacia.Stubs.OutlookWrappers
override public string EntryID { get { return _item.EntryID; } }
override public IFolder Parent
override protected IFolder ParentUnchecked
{
get
{
@ -83,27 +83,6 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
override public string ParentEntryID
{
get
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
}
}
}
override public IStore GetStore()
{
using (ComRelease com = new ComRelease())
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return Mapping.Wrap(parent?.Store);
}
}
override public void Delete() { _item.Delete(); }
#endregion

View File

@ -49,7 +49,7 @@ namespace Acacia.ZPush
public override bool IsApplicable(IFolder folder)
{
return folder.ItemType == _itemType;
return folder != null && folder.ItemType == _itemType;
}
public override string ToString()
@ -71,6 +71,8 @@ namespace Acacia.ZPush
public override bool IsApplicable(IFolder folder)
{
if (folder == null)
return false;
// TODO: cache folder id per store
using (IStore store = folder.GetStore())
{