diff --git a/mRemoteV1/Connection/ConnectionInitiator.cs b/mRemoteV1/Connection/ConnectionInitiator.cs
index 86ae32439..a973c27bf 100644
--- a/mRemoteV1/Connection/ConnectionInitiator.cs
+++ b/mRemoteV1/Connection/ConnectionInitiator.cs
@@ -1,6 +1,5 @@
using mRemoteNG.App;
using mRemoteNG.Connection.Protocol;
-using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Container;
using mRemoteNG.Messages;
using mRemoteNG.UI.Forms;
@@ -204,25 +203,27 @@ namespace mRemoteNG.Connection
#endregion
#region Event handlers
- private static void Prot_Event_Disconnected(object sender, string disconnectedMessage)
+ private static void Prot_Event_Disconnected(object sender, string disconnectedMessage, int? reasonCode)
{
try
{
- if (sender is VncSharp.RemoteDesktop)
+ var prot = (ProtocolBase)sender;
+ var msgClass = MessageClass.InformationMsg;
+
+ if (prot.InterfaceControl.Info.Protocol == ProtocolType.RDP)
{
- Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, @"VncSharp Disconnected."), true);
- return;
+ if (reasonCode > 3)
+ {
+ msgClass = MessageClass.WarningMsg;
+ }
}
- Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, disconnectedMessage), true);
-
- var prot = (ProtocolBase)sender;
- if (prot.InterfaceControl.Info.Protocol != ProtocolType.RDP) return;
- var reasonCode = disconnectedMessage.Split("\r\n".ToCharArray())[0];
- var desc = disconnectedMessage.Replace("\r\n", " ");
-
- if (Convert.ToInt32(reasonCode) > 3)
- Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strRdpDisconnected + Environment.NewLine + desc);
+ Runtime.MessageCollector.AddMessage(msgClass,
+ string.Format(
+ Language.strProtocolEventDisconnected,
+ disconnectedMessage,
+ prot.InterfaceControl.Info.Hostname,
+ prot.InterfaceControl.Info.Protocol.ToString()));
}
catch (Exception ex)
{
@@ -266,16 +267,18 @@ namespace mRemoteNG.Connection
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strConnectionEventConnectedDetail, prot.InterfaceControl.Info.Hostname, prot.InterfaceControl.Info.Protocol, Environment.UserName, prot.InterfaceControl.Info.Description, prot.InterfaceControl.Info.UserField));
}
- private static void Prot_Event_ErrorOccured(object sender, string errorMessage)
+ private static void Prot_Event_ErrorOccured(object sender, string errorMessage, int? errorCode)
{
try
{
- Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventErrorOccured, true);
- var prot = (ProtocolBase)sender;
+ var prot = (ProtocolBase) sender;
- if (prot.InterfaceControl.Info.Protocol != ProtocolType.RDP) return;
- if (Convert.ToInt32(errorMessage) > -1)
- Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strConnectionRdpErrorDetail, errorMessage, RdpErrorCodes.GetError(errorMessage)));
+ var msg = string.Format(
+ Language.strConnectionEventErrorOccured,
+ errorMessage,
+ prot.InterfaceControl.Info.Hostname,
+ errorCode?.ToString() ?? "-");
+ Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, msg);
}
catch (Exception ex)
{
diff --git a/mRemoteV1/Connection/Protocol/ICA/IcaProtocol.cs b/mRemoteV1/Connection/Protocol/ICA/IcaProtocol.cs
index e28c21147..795e6494c 100644
--- a/mRemoteV1/Connection/Protocol/ICA/IcaProtocol.cs
+++ b/mRemoteV1/Connection/Protocol/ICA/IcaProtocol.cs
@@ -285,12 +285,12 @@ namespace mRemoteNG.Connection.Protocol.ICA
private void ICAEvent_OnConnectFailed(object sender, EventArgs e)
{
- Event_ErrorOccured(this, e.ToString());
+ Event_ErrorOccured(this, e.ToString(), null);
}
private void ICAEvent_OnDisconnect(object sender, EventArgs e)
{
- Event_Disconnected(this, e.ToString());
+ Event_Disconnected(this, e.ToString(), null);
if (Settings.Default.ReconnectOnDisconnect)
{
diff --git a/mRemoteV1/Connection/Protocol/ProtocolBase.cs b/mRemoteV1/Connection/Protocol/ProtocolBase.cs
index b9008b03c..15bb49bff 100644
--- a/mRemoteV1/Connection/Protocol/ProtocolBase.cs
+++ b/mRemoteV1/Connection/Protocol/ProtocolBase.cs
@@ -1,13 +1,13 @@
+using mRemoteNG.App;
+using mRemoteNG.Tools;
using System;
using System.Threading;
using System.Windows.Forms;
-using mRemoteNG.App;
-using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol
{
- public abstract class ProtocolBase
+ public abstract class ProtocolBase
{
#region Private Variables
@@ -239,14 +239,14 @@ namespace mRemoteNG.Connection.Protocol
remove { ConnectedEvent = (ConnectedEventHandler) Delegate.Remove(ConnectedEvent, value); }
}
- public delegate void DisconnectedEventHandler(object sender, string DisconnectedMessage);
+ public delegate void DisconnectedEventHandler(object sender, string disconnectedMessage, int? reasonCode);
public event DisconnectedEventHandler Disconnected
{
add { DisconnectedEvent = (DisconnectedEventHandler) Delegate.Combine(DisconnectedEvent, value); }
remove { DisconnectedEvent = (DisconnectedEventHandler) Delegate.Remove(DisconnectedEvent, value); }
}
- public delegate void ErrorOccuredEventHandler(object sender, string ErrorMessage);
+ public delegate void ErrorOccuredEventHandler(object sender, string errorMessage, int? errorCode);
public event ErrorOccuredEventHandler ErrorOccured
{
add { ErrorOccuredEvent = (ErrorOccuredEventHandler) Delegate.Combine(ErrorOccuredEvent, value); }
@@ -288,14 +288,14 @@ namespace mRemoteNG.Connection.Protocol
ConnectedEvent?.Invoke(sender);
}
- protected void Event_Disconnected(object sender, string DisconnectedMessage)
+ protected void Event_Disconnected(object sender, string disconnectedMessage, int? reasonCode)
{
- DisconnectedEvent?.Invoke(sender, DisconnectedMessage);
+ DisconnectedEvent?.Invoke(sender, disconnectedMessage, reasonCode);
}
- protected void Event_ErrorOccured(object sender, string ErrorMsg)
+ protected void Event_ErrorOccured(object sender, string errorMsg, int? errorCode)
{
- ErrorOccuredEvent?.Invoke(sender, ErrorMsg);
+ ErrorOccuredEvent?.Invoke(sender, errorMsg, errorCode);
}
protected void Event_ReconnectGroupCloseClicked()
diff --git a/mRemoteV1/Connection/Protocol/RDP/RdpErrorCodes.cs b/mRemoteV1/Connection/Protocol/RDP/RdpErrorCodes.cs
index fa98147b6..aa963ffd2 100644
--- a/mRemoteV1/Connection/Protocol/RDP/RdpErrorCodes.cs
+++ b/mRemoteV1/Connection/Protocol/RDP/RdpErrorCodes.cs
@@ -1,6 +1,6 @@
+using mRemoteNG.App;
using System;
using System.Collections;
-using mRemoteNG.App;
namespace mRemoteNG.Connection.Protocol.RDP
{
@@ -12,19 +12,19 @@ namespace mRemoteNG.Connection.Protocol.RDP
{
_description = new Hashtable
{
- {"0", "Language.strRdpErrorUnknown"},
- {"1", "Language.strRdpErrorCode1"},
- {"2", "Language.strRdpErrorOutOfMemory"},
- {"3", "Language.strRdpErrorWindowCreation"},
- {"4", "Language.strRdpErrorCode2"},
- {"5", "Language.strRdpErrorCode3"},
- {"6", "Language.strRdpErrorCode4"},
- {"7", "Language.strRdpErrorConnection"},
- {"100", "Language.strRdpErrorWinsock"}
+ { 0, "Language.strRdpErrorUnknown"},
+ { 1, "Language.strRdpErrorCode1"},
+ { 2, "Language.strRdpErrorOutOfMemory"},
+ { 3, "Language.strRdpErrorWindowCreation"},
+ { 4, "Language.strRdpErrorCode2"},
+ { 5, "Language.strRdpErrorCode3"},
+ { 6, "Language.strRdpErrorCode4"},
+ { 7, "Language.strRdpErrorConnection"},
+ { 100, "Language.strRdpErrorWinsock"}
};
}
- public static string GetError(string id)
+ public static string GetError(int id)
{
try
{
diff --git a/mRemoteV1/Connection/Protocol/RDP/RdpProtocol.cs b/mRemoteV1/Connection/Protocol/RDP/RdpProtocol.cs
index 0feb886c6..40317306c 100644
--- a/mRemoteV1/Connection/Protocol/RDP/RdpProtocol.cs
+++ b/mRemoteV1/Connection/Protocol/RDP/RdpProtocol.cs
@@ -690,8 +690,9 @@ namespace mRemoteNG.Connection.Protocol.RDP
private void RDPEvent_OnFatalError(int errorCode)
- {
- Event_ErrorOccured(this, Convert.ToString(errorCode));
+ {
+ var errorMsg = RdpErrorCodes.GetError(errorCode);
+ Event_ErrorOccured(this, errorMsg, errorCode);
}
private void RDPEvent_OnDisconnected(int discReason)
@@ -700,7 +701,7 @@ namespace mRemoteNG.Connection.Protocol.RDP
if (discReason != UI_ERR_NORMAL_DISCONNECT)
{
var reason = _rdpClient.GetErrorDescription((uint)discReason, (uint) _rdpClient.ExtendedDisconnectReason);
- Event_Disconnected(this, discReason + "\r\n" + reason);
+ Event_Disconnected(this, reason, discReason);
}
if (Settings.Default.ReconnectOnDisconnect)
diff --git a/mRemoteV1/Connection/Protocol/VNC/Connection.Protocol.VNC.cs b/mRemoteV1/Connection/Protocol/VNC/Connection.Protocol.VNC.cs
index a405a5760..63db3a924 100644
--- a/mRemoteV1/Connection/Protocol/VNC/Connection.Protocol.VNC.cs
+++ b/mRemoteV1/Connection/Protocol/VNC/Connection.Protocol.VNC.cs
@@ -186,7 +186,7 @@ namespace mRemoteNG.Connection.Protocol.VNC
private void VNCEvent_Disconnected(object sender, EventArgs e)
{
FrmMain.ClipboardChanged -= VNCEvent_ClipboardChanged;
- Event_Disconnected(sender, e.ToString());
+ Event_Disconnected(sender, @"VncSharp Disconnected.", null);
Close();
}
diff --git a/mRemoteV1/Resources/Language/Language.Designer.cs b/mRemoteV1/Resources/Language/Language.Designer.cs
index 1a9d0d0b4..da008ab3f 100644
--- a/mRemoteV1/Resources/Language/Language.Designer.cs
+++ b/mRemoteV1/Resources/Language/Language.Designer.cs
@@ -1473,7 +1473,7 @@ namespace mRemoteNG {
}
///
- /// Looks up a localized string similar to Protocol Event ErrorOccured.
+ /// Looks up a localized string similar to A connection protocol error occurred. Host: "{1}"; Error code: "{2}"; Error Description: "{0}".
///
internal static string strConnectionEventErrorOccured {
get {
@@ -5551,9 +5551,7 @@ namespace mRemoteNG {
}
///
- /// Looks up a localized string similar to Protocol Event Disconnected.
- ///Message:
- ///{0}.
+ /// Looks up a localized string similar to Protocol Event Disconnected. Host: "{1}"; Protocol: "{2}" Message: "{0}".
///
internal static string strProtocolEventDisconnected {
get {
diff --git a/mRemoteV1/Resources/Language/Language.resx b/mRemoteV1/Resources/Language/Language.resx
index 40e615227..c124008ae 100644
--- a/mRemoteV1/Resources/Language/Language.resx
+++ b/mRemoteV1/Resources/Language/Language.resx
@@ -508,7 +508,7 @@ VncSharp Control Version {0}
Connection failed!
- Protocol Event ErrorOccured
+ A connection protocol error occurred. Host: "{1}"; Error code: "{2}"; Error Description: "{0}"
Opening connection failed!
@@ -1683,9 +1683,7 @@ If you run into such an error, please create a new connection file!
Proxy Username
- Protocol Event Disconnected.
-Message:
-{0}
+ Protocol Event Disconnected. Host: "{1}"; Protocol: "{2}" Message: "{0}"
Protocol Event Disconnected failed.