From 08c771d7624ec7e70b7d8d189f8a5e4ac2a8c2f1 Mon Sep 17 00:00:00 2001 From: Patrick Simpson Date: Tue, 28 Feb 2017 16:08:57 +0100 Subject: [PATCH] [KOE-12] Added debug option to disable COM code, which is the one bit that might cause a crash. --- .../SharedFolders/FeatureSharedFolders.cs | 14 ++++++ .../SharedFolders/SharedFoldersManager.cs | 47 +++++++++++-------- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs index a01c5f4..783ec46 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs @@ -26,6 +26,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using static Acacia.DebugOptions; namespace Acacia.Features.SharedFolders { @@ -34,6 +35,19 @@ namespace Acacia.Features.SharedFolders : Feature, FeatureWithRibbon, FeatureWithContextMenu { + #region Debug options + + [AcaciaOption("Disables the update of the reminders query. If this is disabled, the reminders flag on " + + "shared folders will be ignored.")] + public bool Reminders + { + get { return GetOption(OPTION_REMINDERS); } + set { SetOption(OPTION_REMINDERS, value); } + } + private static readonly BoolOption OPTION_REMINDERS = new BoolOption("Reminders", true); + + #endregion + public override void Startup() { RegisterButton(this, "SharedFolders", true, ManageFolders, ZPushBehaviour.Disable); diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersManager.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersManager.cs index 58cfa60..e87fc3e 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersManager.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersManager.cs @@ -62,15 +62,18 @@ namespace Acacia.Features.SharedFolders // Fetch the shares ICollection shares = _api.GetCurrentShares(cancel); - // Make sure reminders are disabled as soon as possible - UpdateReminders(shares); + if (_feature.Reminders) + { + // Make sure reminders are disabled as soon as possible + UpdateReminders(shares); - // Remove any reminders from the shares that are not wanted, they are stale - OpenQuery()?.RemoveStaleReminders( - shares - .Where(x => x.IsSynced && x.SyncType.IsAppointment() && x.FlagCalendarReminders) - .Select(x => x.SyncId) - ); + // Remove any reminders from the shares that are not wanted, they are stale + OpenQuery()?.RemoveStaleReminders( + shares + .Where(x => x.IsSynced && x.SyncType.IsAppointment() && x.FlagCalendarReminders) + .Select(x => x.SyncId) + ); + } // Commit changes if (_query != null) @@ -90,12 +93,15 @@ namespace Acacia.Features.SharedFolders private void UpdateReminders(ICollection shares) { - foreach(SharedFolder share in shares) + if (_feature.Reminders) { - Logger.Instance.Debug(this, "UpdateReminders: {0}", share); - if (share.IsSynced && share.SyncType.IsAppointment()) + foreach (SharedFolder share in shares) { - OpenQuery()?.UpdateReminders(share.SyncId, share.FlagCalendarReminders); + Logger.Instance.Debug(this, "UpdateReminders: {0}", share); + if (share.IsSynced && share.SyncType.IsAppointment()) + { + OpenQuery()?.UpdateReminders(share.SyncId, share.FlagCalendarReminders); + } } } } @@ -104,14 +110,17 @@ namespace Acacia.Features.SharedFolders { if (_query == null) { - RemindersQuery query = new RemindersQuery(_feature, _account.Account.Store); - if (query.Open()) + if (_feature.Reminders) { - _query = query; - } - else - { - query.Dispose(); + RemindersQuery query = new RemindersQuery(_feature, _account.Account.Store); + if (query.Open()) + { + _query = query; + } + else + { + query.Dispose(); + } } } return _query;