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;
// 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;
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()
{
return new AddressBookWrapper(CloneComObject());

View File

@ -343,10 +343,8 @@ namespace Acacia.Stubs.OutlookWrappers
{
if (_beforeItemMove != null)
{
// TODO: there is a tiny potential for a leak here, if there is an exception in the wrap methods. Should
// only happen if Outlook sends the wrong type object though
using (IItem itemWrapped = Mapping.Wrap<IItem>(item))
using (IFolder targetWrapped = Mapping.Wrap<IFolder>(target))
using (IItem itemWrapped = Mapping.Wrap<IItem>(item, false))
using (IFolder targetWrapped = Mapping.Wrap<IFolder>(target, false))
{
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)
{

View File

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

View File

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

View File

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

View File

@ -49,17 +49,18 @@ namespace Acacia.Stubs.OutlookWrappers
public void Start()
{
// Check existing stores
// TODO: do this in background?
foreach(NSOutlook.Store store in _item)
{
StoreAdded(store);
Tasks.Task(null, "AddStore", () =>
{
StoreAdded(store);
});
}
// Register for new stores
// The store remove event is not sent, so don't bother registering for that
_item.StoreAdd += StoreAdded;
if (GlobalOptions.INSTANCE.AccountTimer)
{
// Set up timer to check for removed accounts
@ -70,42 +71,59 @@ namespace Acacia.Stubs.OutlookWrappers
/// <summary>
/// Event handler for Stores.StoreAdded event.
/// </summary>
private void StoreAdded(NSOutlook.Store s)
private void Event_StoreAdded(NSOutlook.Store _)
{
IStore store = null;
try
{
// 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)
{
if (!_accountsByStoreId.ContainsKey(rawStore.StoreID))
{
store = new StoreWrapper(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);
}
StoreAdded(rawStore);
}
else ComRelease.Release(rawStore);
}
}
catch (System.Exception e)
{
Logger.Instance.Error(this, "StoreAdded Exception: {0}", e);
if (store != null)
store.Dispose();
Logger.Instance.Error(this, "Event_StoreAdded Exception: {0}", e);
}
}
/// <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();
}
}