mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
[KOE-161] Added limit to number of allowed shared folders
This commit is contained in:
parent
b5fdc335e9
commit
f5076876a3
@ -174,6 +174,42 @@ namespace Acacia
|
||||
|
||||
}
|
||||
|
||||
public class IntOption : Option<int>
|
||||
{
|
||||
private readonly int _defaultValue;
|
||||
|
||||
public IntOption(string token, int defaultValue)
|
||||
:
|
||||
base(token)
|
||||
{
|
||||
this._defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public override string GetToken(int value)
|
||||
{
|
||||
if (value.Equals(_defaultValue))
|
||||
return null;
|
||||
return Token + "=" + value.ToString();
|
||||
}
|
||||
|
||||
public override int GetValue(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return _defaultValue;
|
||||
else
|
||||
{
|
||||
if (value.ToLower().StartsWith(Token.ToLower() + "="))
|
||||
value = value.Substring(Token.Length + 1);
|
||||
|
||||
int result;
|
||||
if (!int.TryParse(value, out result))
|
||||
return _defaultValue;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// General
|
||||
public static readonly BoolOption ENABLED = new BoolOption("", true);
|
||||
public static readonly BoolOption FEATURE_DISABLED_DEFAULT = new BoolOption("", false);
|
||||
|
@ -75,6 +75,15 @@ namespace Acacia.Features.SharedFolders
|
||||
}
|
||||
private static readonly BoolOption OPTION_ALLOW_IMPERSONATE = new BoolOption("AllowImpersonate", false);
|
||||
|
||||
|
||||
[AcaciaOption("The maximum number of shared folders before an error is shown. Defaults to 50.")]
|
||||
public int MaxFolderCount
|
||||
{
|
||||
get { return GetOption(OPTION_MAX_FOLDER_COUNT); }
|
||||
set { SetOption(OPTION_MAX_FOLDER_COUNT, value); }
|
||||
}
|
||||
private static readonly IntOption OPTION_MAX_FOLDER_COUNT = new IntOption("MaxFolderCount", 50);
|
||||
|
||||
#endregion
|
||||
|
||||
public override void Startup()
|
||||
|
@ -262,9 +262,14 @@ namespace Acacia.Features.SharedFolders
|
||||
|
||||
private void dialogButtons_Apply(object sender, EventArgs e)
|
||||
{
|
||||
int folderCount = 0;
|
||||
|
||||
// Check if all fields are properly set
|
||||
foreach (StoreTreeNode storeNode in _userFolders.Values)
|
||||
{
|
||||
// Check totals
|
||||
folderCount += storeNode.CurrentShares.Count();
|
||||
|
||||
// Check modified folders
|
||||
if (storeNode.IsDirty)
|
||||
{
|
||||
@ -294,7 +299,19 @@ namespace Acacia.Features.SharedFolders
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check total number of folders
|
||||
if (folderCount >= _feature.MaxFolderCount)
|
||||
{
|
||||
MessageBox.Show(ThisAddIn.Instance.Window,
|
||||
Properties.Resources.SharedFolders_TooManyFolders_Body,
|
||||
Properties.Resources.SharedFolders_TooManyFolders_Title,
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
// And don't apply anything
|
||||
return;
|
||||
}
|
||||
|
||||
BusyText = Properties.Resources.SharedFolders_Applying_Label;
|
||||
KUITask.New((ctx) =>
|
||||
|
@ -1211,6 +1211,24 @@ namespace Acacia.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You are trying to open many additional folders. Having many shared folders open can impact the stability of Outlook. When working with many shared folders its recommended to take a look at Kopano WebApp/DeskApp instead..
|
||||
/// </summary>
|
||||
internal static string SharedFolders_TooManyFolders_Body {
|
||||
get {
|
||||
return ResourceManager.GetString("SharedFolders_TooManyFolders_Body", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shared Folders.
|
||||
/// </summary>
|
||||
internal static string SharedFolders_TooManyFolders_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("SharedFolders_TooManyFolders_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to There are unsaved changes. Do you really want to to discard these?.
|
||||
/// </summary>
|
||||
|
@ -545,4 +545,10 @@ Please contact your system administrator for any required changes.</value>
|
||||
<data name="LocalStore_Move_Title" xml:space="preserve">
|
||||
<value>Kopano Folders</value>
|
||||
</data>
|
||||
<data name="SharedFolders_TooManyFolders_Body" xml:space="preserve">
|
||||
<value>You are trying to open many additional folders. Having many shared folders open can impact the stability of Outlook. When working with many shared folders its recommended to take a look at Kopano WebApp/DeskApp instead.</value>
|
||||
</data>
|
||||
<data name="SharedFolders_TooManyFolders_Title" xml:space="preserve">
|
||||
<value>Shared Folders</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user