Skip to content

Commit

Permalink
Add default configuration files (#30)
Browse files Browse the repository at this point in the history
* Add default configuration files

The default configuration files are Common.txt, TrustedDomains.txt, UnsafeDomains.txt and UnsafeFiles.txt in `{app}\DefaultConfig`.
Those files are installed when they are located in the "DefaultConfig" folder that exits in the same folder to installer like below.

```
│  FlexConfirmMailSetup-22.6.0.exe
│
└─DefaultConfig
        Common.txt
        TrustedDomains.txt
        UnsafeDomains.txt
```

The configurations in the policy configuration and the default configuration files for trusted domains, unsafe domains and unsafe files
are fixed, they can't modified by user configuration files.
The priority of common configurations is as following.

User file configurations > Default file configurations > Policy configurations

* Bump version to 22.7.0

* add a new line

* Remove a needless using
  • Loading branch information
HashidaTKS authored Jun 19, 2024
1 parent 6df45c1 commit 23a2567
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Config/Const.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public class RegistryPath
public static readonly string Policy = @"SOFTWARE\Policies\FlexConfirmMail";
}

public class ConfigPath
{
public static readonly string DefaultConfigDirName = @"DefaultConfig";
}

public enum ConfigOption
{
CountEnabled,
Expand Down
7 changes: 6 additions & 1 deletion Config/StandardPath.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;

using System.IO;

namespace FlexConfirmMail
Expand All @@ -10,6 +9,12 @@ public static string GetUserDir()
{
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
return Path.Combine(appData, Global.AppName);
}

public static string GetDefaultConfigDir()
{
string dllDirectory = AppDomain.CurrentDomain.BaseDirectory;
return Path.Combine(dllDirectory, ConfigPath.DefaultConfigDirName);
}
}
}
7 changes: 5 additions & 2 deletions Dialog/ConfigDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace FlexConfirmMail.Dialog
public partial class ConfigDialog : Window
{
Config _config = new Config();
Config _default = new Config();
Config _default = new Config();
Config _local = new Config();

public ConfigDialog()
Expand All @@ -24,7 +24,10 @@ public ConfigDialog()
{
_default = Loader.LoadFromReg(RegistryPath.DefaultPolicy);
_config.Merge(_default);
}
}
Config defaultWithFile = Loader.LoadFromDir(StandardPath.GetDefaultConfigDir());
_default.Merge(defaultWithFile);
_config.Merge(defaultWithFile);

_local = Loader.LoadFromDir(StandardPath.GetUserDir());
_config.Merge(_local);
Expand Down
7 changes: 4 additions & 3 deletions FlexConfirmMail.iss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[Setup]
AppName=FlexConfirmMail
AppVerName=FlexConfirmMail
VersionInfoVersion=22.6.0
VersionInfoVersion=22.7.0
AppPublisher=ClearCode Inc.
AppVersion=22.6.0
AppVersion=22.7.0
UninstallDisplayIcon={app}\fcm.ico
DefaultDirName={commonpf}\FlexConfirmMail
ShowLanguageDialog=no
Expand Down Expand Up @@ -42,8 +42,9 @@ Source: "bin\Release\FlexConfirmMail.dll"; DestDir: "{app}"; Flags: ignoreversio
Source: "bin\Release\FlexConfirmMail.dll.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\FlexConfirmMail.vsto"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\en\FlexConfirmMail.resources.dll"; DestDir: "{app}\en"; Flags: ignoreversion
Source: "bin\Release\zh\FlexConfirmMail.resources.dll"; DestDir: "{app}\zh"; Flags: ignoreversion
Source: "bin\Release\zh\FlexConfirmMail.resources.dll"; DestDir: "{app}\zh"; Flags: ignoreversion
Source: "bin\Release\es\FlexConfirmMail.resources.dll"; DestDir: "{app}\es"; Flags: ignoreversion
Source: "bin\Release\Microsoft.Office.Tools.Common.v4.0.Utilities.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\Microsoft.Office.Tools.Outlook.v4.0.Utilities.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "Resources\fcm.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "{src}\DefaultConfig\*.txt"; DestDir: "{app}\DefaultConfig"; Flags:external skipifsourcedoesntexist
2 changes: 1 addition & 1 deletion Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace FlexConfirmMail
public class Global
{
public static readonly string AppName = "FlexConfirmMail";
public static readonly string Version = "22.6.0";
public static readonly string Version = "22.7.0";
public static readonly string Edition = "Enterprise";
public static readonly bool EnableGPO = true;
}
Expand Down
5 changes: 3 additions & 2 deletions ThisAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Windows.Media;
using System.Windows.Interop;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Collections.Generic;
using System.Collections.Generic;

namespace FlexConfirmMail
{
Expand Down Expand Up @@ -158,7 +158,8 @@ private bool DoCheck(Outlook.MailItem mail)
if (Global.EnableGPO)
{
config.Merge(Loader.LoadFromReg(RegistryPath.DefaultPolicy));
}
}
config.Merge(Loader.LoadFromDir(StandardPath.GetDefaultConfigDir()));
config.Merge(Loader.LoadFromDir(StandardPath.GetUserDir()));

List<RecipientInfo> originalRecipients = GetOriginalRecipientsFromDictionary(mail.EntryID);
Expand Down

0 comments on commit 23a2567

Please sign in to comment.