mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Small cleanups. Made HookItemEvents disabled by default. Restored DebugSupport buttons.
This commit is contained in:
parent
5842e90203
commit
a56cb98ce8
@ -48,16 +48,16 @@ namespace Acacia.Features.DebugSupport
|
|||||||
|
|
||||||
public override void AfterStartup()
|
public override void AfterStartup()
|
||||||
{
|
{
|
||||||
//ShowAbout();
|
/*DebugDialog dd = new DebugDialog();
|
||||||
|
dd.Show();
|
||||||
|
dd.DebugCycle(5);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#region About dialog
|
#region About dialog
|
||||||
|
|
||||||
public void ShowAbout()
|
public void ShowAbout()
|
||||||
{
|
{
|
||||||
DebugDialog dd = new DebugDialog();
|
new AboutDialog().ShowDialog();
|
||||||
dd.Show();
|
|
||||||
dd.DebugCycle(5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -79,9 +79,7 @@ namespace Acacia.Features.DebugSupport
|
|||||||
|
|
||||||
public void ShowSettings()
|
public void ShowSettings()
|
||||||
{
|
{
|
||||||
//new SettingsDialog().ShowDialog();
|
new SettingsDialog().ShowDialog();
|
||||||
ThisAddIn.Instance.GetFeature<GAB.FeatureGAB>()?.FullResync();
|
|
||||||
Tasks.Task(this, "GC", () => Util.GarbageCollect());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override FeatureSettings GetSettings()
|
public override FeatureSettings GetSettings()
|
||||||
|
@ -125,7 +125,7 @@ namespace Acacia
|
|||||||
get { return GetOption(null, HOOK_ITEM_EVENTS); }
|
get { return GetOption(null, HOOK_ITEM_EVENTS); }
|
||||||
set { SetOption(null, HOOK_ITEM_EVENTS, value); }
|
set { SetOption(null, HOOK_ITEM_EVENTS, value); }
|
||||||
}
|
}
|
||||||
private static readonly BoolOption HOOK_ITEM_EVENTS = new BoolOption("HookItemEvents", true);
|
private static readonly BoolOption HOOK_ITEM_EVENTS = new BoolOption("HookItemEvents", false);
|
||||||
|
|
||||||
#region UI Options
|
#region UI Options
|
||||||
|
|
||||||
|
@ -13,5 +13,11 @@ namespace Acacia.Stubs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The command bars. The caller is responsible for disposing.</returns>
|
/// <returns>The command bars. The caller is responsible for disposing.</returns>
|
||||||
ICommandBars GetCommandBars();
|
ICommandBars GetCommandBars();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the currently selected folder, or null if no folder is selected.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The folder. The caller is responsible for disposing.</returns>
|
||||||
|
IFolder GetCurrentFolder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,5 +106,9 @@ namespace Acacia.Stubs
|
|||||||
/// function prevents creating lots of wrappers.
|
/// function prevents creating lots of wrappers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsAtDepth(int depth);
|
bool IsAtDepth(int depth);
|
||||||
|
|
||||||
|
// TODO: remove this. It's a quick hack to find the events associated with this folder for ZPushWatcher.
|
||||||
|
// make event watching part of the folder instead
|
||||||
|
ZPushFolder ZPush { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,10 +88,7 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
|
|
||||||
public IExplorer GetActiveExplorer()
|
public IExplorer GetActiveExplorer()
|
||||||
{
|
{
|
||||||
using (ComRelease com = new ComRelease())
|
return new ExplorerWrapper(_app.ActiveExplorer());
|
||||||
{
|
|
||||||
return new ExplorerWrapper(com.Add(_thisAddIn.Application).ActiveExplorer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Window handle
|
#region Window handle
|
||||||
|
@ -14,9 +14,19 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void DoRelease()
|
||||||
|
{
|
||||||
|
base.DoRelease();
|
||||||
|
}
|
||||||
|
|
||||||
public ICommandBars GetCommandBars()
|
public ICommandBars GetCommandBars()
|
||||||
{
|
{
|
||||||
return new CommandBarsWrapper(_item.CommandBars);
|
return new CommandBarsWrapper(_item.CommandBars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IFolder GetCurrentFolder()
|
||||||
|
{
|
||||||
|
return _item.CurrentFolder.Wrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,5 +467,11 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
{
|
{
|
||||||
get { return (ItemType)(int)_item.DefaultItemType; }
|
get { return (ItemType)(int)_item.DefaultItemType; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ZPushFolder ZPush
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,18 +36,30 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
return new FolderWrapper((NSOutlook.Folder)_item.GetRootFolder());
|
return new FolderWrapper((NSOutlook.Folder)_item.GetRootFolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NSOutlook.MAPIFolder GetDefaultFolderObj(DefaultFolder folder)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (NSOutlook.Folder)_item.GetDefaultFolder((NSOutlook.OlDefaultFolders)(int)folder);
|
||||||
|
}
|
||||||
|
catch(Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IFolder GetDefaultFolder(DefaultFolder folder)
|
public IFolder GetDefaultFolder(DefaultFolder folder)
|
||||||
{
|
{
|
||||||
// FolderWrapper manages the returned Folder
|
// FolderWrapper manages the returned Folder
|
||||||
return new FolderWrapper((NSOutlook.Folder)_item.GetDefaultFolder((NSOutlook.OlDefaultFolders)(int)folder));
|
return GetDefaultFolderObj(folder).Wrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetDefaultFolderId(DefaultFolder folder)
|
public string GetDefaultFolderId(DefaultFolder folder)
|
||||||
{
|
{
|
||||||
NSOutlook.MAPIFolder mapiFolder = _item.GetDefaultFolder((NSOutlook.OlDefaultFolders)(int)folder);
|
NSOutlook.MAPIFolder mapiFolder = GetDefaultFolderObj(folder);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return mapiFolder.EntryID;
|
return mapiFolder?.EntryID;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Acacia.Stubs.OutlookWrappers;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -11,7 +12,7 @@ namespace Acacia.Stubs
|
|||||||
{
|
{
|
||||||
public static IFolder Wrap(this NSOutlook.MAPIFolder obj)
|
public static IFolder Wrap(this NSOutlook.MAPIFolder obj)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException(); // TODO
|
return Mapping.WrapOrDefault<IFolder>(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ using System.Security;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NSOutlook = Microsoft.Office.Interop.Outlook;
|
|
||||||
|
|
||||||
namespace Acacia.ZPush
|
namespace Acacia.ZPush
|
||||||
{
|
{
|
||||||
|
@ -293,7 +293,7 @@ namespace Acacia.ZPush
|
|||||||
/// <param name="account">The account. The caller is responsible for releasing this.</param>
|
/// <param name="account">The account. The caller is responsible for releasing this.</param>
|
||||||
/// <returns>The associated ZPushAccount</returns>
|
/// <returns>The associated ZPushAccount</returns>
|
||||||
/// <exception cref="Exception">If the registry key cannot be found</exception>
|
/// <exception cref="Exception">If the registry key cannot be found</exception>
|
||||||
// TODO: check management of account
|
// TODO: check owner
|
||||||
private ZPushAccount CreateFromRegistry(NSOutlook.Account account)
|
private ZPushAccount CreateFromRegistry(NSOutlook.Account account)
|
||||||
{
|
{
|
||||||
// TODO: check that caller releases account everywhere
|
// TODO: check that caller releases account everywhere
|
||||||
|
@ -50,14 +50,16 @@ namespace Acacia.ZPush
|
|||||||
this._parent = parent;
|
this._parent = parent;
|
||||||
this._watcher = watcher;
|
this._watcher = watcher;
|
||||||
this._folder = folder;
|
this._folder = folder;
|
||||||
|
folder.ZPush = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DoRelease()
|
protected override void DoRelease()
|
||||||
{
|
{
|
||||||
|
Cleanup();
|
||||||
_folder.Dispose();
|
_folder.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFolder Folder { get; }
|
public IFolder Folder { get { return _folder; } }
|
||||||
public string Name { get { return _folder.Name; } }
|
public string Name { get { return _folder.Name; } }
|
||||||
|
|
||||||
private void Initialise()
|
private void Initialise()
|
||||||
@ -75,16 +77,6 @@ namespace Acacia.ZPush
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
/*public override void Dispose()
|
|
||||||
{
|
|
||||||
Logger.Instance.Trace(this, "Disposing folder: {0}", _item.Name);
|
|
||||||
Cleanup();
|
|
||||||
base.Dispose();
|
|
||||||
ComRelease.Release(_items);
|
|
||||||
ComRelease.Release(_subFolders);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
internal ItemsWatcher ItemsWatcher()
|
internal ItemsWatcher ItemsWatcher()
|
||||||
{
|
{
|
||||||
ItemsWatcher watcher = new ItemsWatcher();
|
ItemsWatcher watcher = new ItemsWatcher();
|
||||||
@ -168,7 +160,7 @@ namespace Acacia.ZPush
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Release the folder if not used
|
// Release the folder if not used
|
||||||
ComRelease.Release(child);
|
child.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,24 +37,27 @@ namespace Acacia.ZPush
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ZPushWatcher
|
public class ZPushWatcher
|
||||||
{
|
{
|
||||||
|
private readonly IAddIn _addIn;
|
||||||
|
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
private readonly NSOutlook.Application _app;
|
private readonly NSOutlook.Application _app;
|
||||||
public readonly ZPushAccounts Accounts;
|
public readonly ZPushAccounts Accounts;
|
||||||
public readonly ZPushSync Sync;
|
public readonly ZPushSync Sync;
|
||||||
private NSOutlook.Explorer _explorer;
|
private NSOutlook.Explorer _explorer2;
|
||||||
|
|
||||||
|
|
||||||
#region Setup
|
#region Setup
|
||||||
|
|
||||||
public ZPushWatcher(IAddIn addIn)
|
public ZPushWatcher(IAddIn addIn)
|
||||||
{
|
{
|
||||||
|
this._addIn = addIn;
|
||||||
this._app = addIn.RawApp;
|
this._app = addIn.RawApp;
|
||||||
Sync = new ZPushSync(this, _app);
|
Sync = new ZPushSync(this, _app);
|
||||||
Accounts = new ZPushAccounts(this, _app);
|
Accounts = new ZPushAccounts(this, _app);
|
||||||
|
|
||||||
// Need to keep a link to keep receiving events
|
// Need to keep a link to keep receiving events
|
||||||
_explorer = _app.ActiveExplorer();
|
_explorer2 = _app.ActiveExplorer();
|
||||||
_explorer.SelectionChange += Explorer_SelectionChange;
|
_explorer2.SelectionChange += Explorer_SelectionChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -208,17 +211,15 @@ namespace Acacia.ZPush
|
|||||||
{
|
{
|
||||||
if (ActiveFolderChange != null)
|
if (ActiveFolderChange != null)
|
||||||
{
|
{
|
||||||
NSOutlook.MAPIFolder active = _explorer.CurrentFolder;
|
|
||||||
if (active != null)
|
using (IFolder folder = _addIn.GetActiveExplorer()?.GetCurrentFolder())
|
||||||
{
|
{
|
||||||
using (IFolder folder = Mapping.Wrap<IFolder>(active))
|
try
|
||||||
{
|
{
|
||||||
try
|
if (folder != null)
|
||||||
{
|
|
||||||
ActiveFolderChange(folder);
|
ActiveFolderChange(folder);
|
||||||
}
|
|
||||||
catch (System.Exception e) { Logger.Instance.Error(this, "Exception in Explorer_SelectionChange.ActiveFolderChange: {0}", e); }
|
|
||||||
}
|
}
|
||||||
|
catch (System.Exception e) { Logger.Instance.Error(this, "Exception in Explorer_SelectionChange.ActiveFolderChange: {0}", e); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: cache value
|
// TODO: cache value
|
||||||
@ -236,18 +237,13 @@ namespace Acacia.ZPush
|
|||||||
|
|
||||||
public ZPushAccount CurrentZPushAccount()
|
public ZPushAccount CurrentZPushAccount()
|
||||||
{
|
{
|
||||||
if (_explorer.CurrentFolder == null)
|
using (IExplorer explorer = _addIn.GetActiveExplorer())
|
||||||
return null;
|
using (IFolder folder = explorer?.GetCurrentFolder())
|
||||||
|
|
||||||
NSOutlook.MAPIFolder folder = _explorer.CurrentFolder;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
|
if (folder == null)
|
||||||
|
return null;
|
||||||
return Accounts.GetAccount(folder);
|
return Accounts.GetAccount(folder);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
ComRelease.Release(folder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -392,17 +388,8 @@ namespace Acacia.ZPush
|
|||||||
if (!DebugOptions.GetOption(null, DebugOptions.WATCHER_ENABLED))
|
if (!DebugOptions.GetOption(null, DebugOptions.WATCHER_ENABLED))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Must have a ZPush folder to watch events, create one if necessary
|
// Must have a ZPush folder to watch events.
|
||||||
ZPushFolder zPushFolder;
|
ZPushFolder zPushFolder = folder.ZPush;
|
||||||
if (!(folder is ZPushFolder))
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
zPushFolder = (ZPushFolder)folder;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register the handlers
|
// Register the handlers
|
||||||
ItemsWatcher watcher = zPushFolder.ItemsWatcher();
|
ItemsWatcher watcher = zPushFolder.ItemsWatcher();
|
||||||
|
Loading…
Reference in New Issue
Block a user