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

Cleaned up more TODOs

This commit is contained in:
Patrick Simpson 2017-02-15 11:32:37 +01:00
parent f687ee9f22
commit 0657c490c8
7 changed files with 48 additions and 39 deletions

View File

@ -327,7 +327,7 @@ namespace Acacia.Features.GAB
return null; return null;
// Scan a few of the newest items, in case there is some junk in the ZPush folder // Scan a few of the newest items, in case there is some junk in the ZPush folder
// TODO: this shouldn't happen in production. // This shouldn't happen in production, but check anyway.
int i = 0; int i = 0;
foreach(IItem item in Folder.Items.Sort("LastModificationTime", true)) foreach(IItem item in Folder.Items.Sort("LastModificationTime", true))
{ {

View File

@ -33,7 +33,6 @@ namespace Acacia.Stubs.OutlookWrappers
} }
// TODO: it would be nice if this could return IAddressBook
public override IFolder Clone() public override IFolder Clone()
{ {
return new AddressBookWrapper(CloneComObject()); return new AddressBookWrapper(CloneComObject());

View File

@ -343,10 +343,8 @@ namespace Acacia.Stubs.OutlookWrappers
{ {
if (_beforeItemMove != null) if (_beforeItemMove != null)
{ {
// TODO: there is a tiny potential for a leak here, if there is an exception in the wrap methods. Should using (IItem itemWrapped = Mapping.Wrap<IItem>(item, false))
// only happen if Outlook sends the wrong type object though using (IFolder targetWrapped = Mapping.Wrap<IFolder>(target, false))
using (IItem itemWrapped = Mapping.Wrap<IItem>(item))
using (IFolder targetWrapped = Mapping.Wrap<IFolder>(target))
{ {
if (itemWrapped != null && targetWrapped != null) if (itemWrapped != null && targetWrapped != null)
{ {
@ -354,11 +352,6 @@ namespace Acacia.Stubs.OutlookWrappers
} }
} }
} }
else
{
// TODO: check this
ComRelease.Release(item, target);
}
} }
catch(System.Exception e) catch(System.Exception e)
{ {

View File

@ -105,7 +105,7 @@ namespace Acacia.Stubs.OutlookWrappers
if (wrapped is Type) if (wrapped is Type)
return (Type)wrapped; return (Type)wrapped;
// TODO: release if required // Release if required
if (wrapped != null) if (wrapped != null)
wrapped.Dispose(); wrapped.Dispose();
return default(Type); return default(Type);

View File

@ -124,7 +124,7 @@ namespace Acacia.Stubs.OutlookWrappers
return null; return null;
return val; return val;
} }
catch(System.Exception) { return null; } // TODO: is this fine everywhere? catch(System.Exception) { return null; }
} }
public void SetProperty(string property, object value) public void SetProperty(string property, object value)

View File

@ -37,7 +37,6 @@ namespace Acacia.Stubs.OutlookWrappers
get get
{ {
return _item.Address; return _item.Address;
// TODO:? return _item.AddressEntry.Address
} }
} }

View File

@ -49,17 +49,18 @@ namespace Acacia.Stubs.OutlookWrappers
public void Start() public void Start()
{ {
// Check existing stores // Check existing stores
// TODO: do this in background?
foreach(NSOutlook.Store store in _item) foreach(NSOutlook.Store store in _item)
{ {
StoreAdded(store); Tasks.Task(null, "AddStore", () =>
{
StoreAdded(store);
});
} }
// Register for new stores // Register for new stores
// The store remove event is not sent, so don't bother registering for that // The store remove event is not sent, so don't bother registering for that
_item.StoreAdd += StoreAdded; _item.StoreAdd += StoreAdded;
if (GlobalOptions.INSTANCE.AccountTimer) if (GlobalOptions.INSTANCE.AccountTimer)
{ {
// Set up timer to check for removed accounts // Set up timer to check for removed accounts
@ -70,42 +71,59 @@ namespace Acacia.Stubs.OutlookWrappers
/// <summary> /// <summary>
/// Event handler for Stores.StoreAdded event. /// Event handler for Stores.StoreAdded event.
/// </summary> /// </summary>
private void StoreAdded(NSOutlook.Store s) private void Event_StoreAdded(NSOutlook.Store _)
{ {
IStore store = null;
try try
{ {
// Accessing the store object causes random crashes, simply iterate to find new stores // Accessing the store object causes random crashes, simply iterate to find new stores
Logger.Instance.Trace(this, "StoreAdded: {0}", s.StoreID); Logger.Instance.Trace(this, "StoreAdded");
foreach (NSOutlook.Store rawStore in _item) foreach (NSOutlook.Store rawStore in _item)
{ {
if (!_accountsByStoreId.ContainsKey(rawStore.StoreID)) if (!_accountsByStoreId.ContainsKey(rawStore.StoreID))
{ {
store = new StoreWrapper(rawStore); StoreAdded(rawStore);
Logger.Instance.Trace(this, "New store: {0}", rawStore.DisplayName);
AccountWrapper account = TryCreateFromRegistry(store);
if (account == null)
{
// Add it to the cache so it is not evaluated again.
_accountsByStoreId.Add(store.StoreID, null);
Logger.Instance.Trace(this, "Not an account store: {0}", store.DisplayName);
store.Dispose();
}
else
{
// Account has taken ownership of the store
Logger.Instance.Trace(this, "New account store: {0}: {1}", store.DisplayName, account);
OnAccountDiscovered(account);
}
} }
else ComRelease.Release(rawStore); else ComRelease.Release(rawStore);
} }
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Logger.Instance.Error(this, "StoreAdded Exception: {0}", e); Logger.Instance.Error(this, "Event_StoreAdded Exception: {0}", e);
if (store != null) }
store.Dispose(); }
/// <summary>
/// Performs the actions required to handle a new store.
/// </summary>
/// <param name="rawStore">The new store. Ownership is transferred</param>
private void StoreAdded(NSOutlook.Store rawStore)
{
IStore store = new StoreWrapper(rawStore);
try
{
Logger.Instance.Trace(this, "New store: {0}", rawStore.DisplayName);
AccountWrapper account = TryCreateFromRegistry(store);
if (account == null)
{
// Add it to the cache so it is not evaluated again.
_accountsByStoreId.Add(store.StoreID, null);
Logger.Instance.Trace(this, "Not an account store: {0}", store.DisplayName);
}
else
{
Logger.Instance.Trace(this, "New account store: {0}: {1}", store.DisplayName, account);
// Account has taken ownership of the store
store = null;
OnAccountDiscovered(account);
}
}
catch (System.Exception e)
{
Logger.Instance.Error(this, "Event_StoreAdded Exception: {0}", e);
}
finally
{
store?.Dispose();
} }
} }