replaced calls to the log4net logger with calls to messagecollector since it is now safe to do so

This commit is contained in:
David Sparer
2017-02-03 14:23:55 -07:00
parent 9cf44c3050
commit 1228f0572d
4 changed files with 34 additions and 24 deletions

View File

@@ -5,22 +5,26 @@ using mRemoteNG.UI.TaskDialog;
using System;
using System.Diagnostics;
using System.Windows.Forms;
using mRemoteNG.Messages;
namespace mRemoteNG.App
{
public static class CompatibilityChecker
{
public static void CheckCompatibility()
public static void CheckCompatibility(MessageCollector messageCollector)
{
CheckFipsPolicy();
CheckLenovoAutoScrollUtility();
CheckFipsPolicy(messageCollector);
CheckLenovoAutoScrollUtility(messageCollector);
}
private static void CheckFipsPolicy()
private static void CheckFipsPolicy(MessageCollector messageCollector)
{
Logger.Instance.InfoFormat("Checking FIPS Policy...");
messageCollector.AddMessage(MessageClass.InformationMsg, "Checking FIPS Policy...", true);
if (!FipsPolicyEnabledForServer2003() && !FipsPolicyEnabledForServer2008AndNewer()) return;
MessageBox.Show(frmMain.Default, string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProductName, GeneralAppInfo.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error));
var errorText = string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProductName,
GeneralAppInfo.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
messageCollector.AddMessage(MessageClass.ErrorMsg, errorText, true);
MessageBox.Show(frmMain.Default, errorText);
Environment.Exit(1);
}
@@ -42,9 +46,9 @@ namespace mRemoteNG.App
return (int)fipsPolicy != 0;
}
private static void CheckLenovoAutoScrollUtility()
private static void CheckLenovoAutoScrollUtility(MessageCollector messageCollector)
{
Logger.Instance.InfoFormat("Checking Lenovo AutoScroll Utility...");
messageCollector.AddMessage(MessageClass.InformationMsg, "Checking Lenovo AutoScroll Utility...", true);
if (!Settings.Default.CompatibilityWarnLenovoAutoScrollUtility)
return;
@@ -56,7 +60,7 @@ namespace mRemoteNG.App
}
catch (InvalidOperationException ex)
{
Runtime.MessageCollector.AddExceptionMessage("Error in CheckLenovoAutoScrollUtility", ex);
messageCollector.AddExceptionMessage("Error in CheckLenovoAutoScrollUtility", ex);
}
if (proccesses.Length <= 0) return;

View File

@@ -4,8 +4,6 @@ using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Management;
using System.Threading;
using System.Windows.Forms;
using mRemoteNG.App.Info;
using mRemoteNG.App.Initialization;
@@ -40,7 +38,7 @@ namespace mRemoteNG.App
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
var startupLogger = new StartupDataLogger(messageCollector);
startupLogger.LogStartupData();
CompatibilityChecker.CheckCompatibility();
CompatibilityChecker.CheckCompatibility(messageCollector);
ParseCommandLineArgs();
IeBrowserEmulation.Register();
GetConnectionIcons();

View File

@@ -1,20 +1,28 @@
using mRemoteNG.App;
using System;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.UI.Forms;
using System;
using System.IO;
using System.Xml;
using mRemoteNG.Messages;
using mRemoteNG.Tools;
namespace mRemoteNG.Config.Settings
{
public class ExternalAppsLoader
{
private readonly frmMain _MainForm;
private readonly frmMain _mainForm;
private readonly MessageCollector _messageCollector;
public ExternalAppsLoader(frmMain MainForm)
public ExternalAppsLoader(frmMain mainForm, MessageCollector messageCollector)
{
_MainForm = MainForm;
if (mainForm == null)
throw new ArgumentNullException(nameof(mainForm));
if (messageCollector == null)
throw new ArgumentNullException(nameof(messageCollector));
_mainForm = mainForm;
_messageCollector = messageCollector;
}
@@ -27,26 +35,26 @@ namespace mRemoteNG.Config.Settings
var xDom = new XmlDocument();
if (File.Exists(newPath))
{
Logger.Instance.Info($"Loading External Apps from: {newPath}");
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {newPath}", true);
xDom.Load(newPath);
}
#if !PORTABLE
else if (File.Exists(oldPath))
{
Logger.Instance.Info($"Loading External Apps from: {oldPath}");
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {oldPath}", true);
xDom.Load(oldPath);
}
#endif
else
{
Logger.Instance.Warn("Loading External Apps failed: Could not FIND file!");
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not FIND file!");
return;
}
if (xDom.DocumentElement == null)
{
Logger.Instance.Warn("Loading External Apps failed: Could not LOAD file!");
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not LOAD file!");
return;
}
@@ -69,11 +77,11 @@ namespace mRemoteNG.Config.Settings
extA.TryIntegrate = bool.Parse(xEl.Attributes["TryToIntegrate"].Value);
}
Logger.Instance.Info($"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}");
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}", true);
Runtime.ExternalTools.Add(extA);
}
_MainForm.SwitchToolBarText(mRemoteNG.Settings.Default.ExtAppsTBShowText);
_mainForm.SwitchToolBarText(mRemoteNG.Settings.Default.ExtAppsTBShowText);
frmMain.Default.AddExternalToolsToToolBar();
}

View File

@@ -31,7 +31,7 @@ namespace mRemoteNG.Config.Settings
throw new ArgumentNullException(nameof(messageCollector));
MainForm = mainForm;
_externalAppsLoader = new ExternalAppsLoader(MainForm);
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector);
_messageCollector = messageCollector;
}