mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-25 06:16:37 +01:00
CA-247333 - Remove rdpclient6 code after April 2017 when it will become redundant
-Removed rdpControl because it is always identical to rdpClient9 -Renamed rdpClient9 to just rdpClient because we use only one client so there is no need to distinguish, and it can easily be updated to future versions. Signed-off-by: Letsibogo Ramadi <letsibogo.ramadi@citrix.com>
This commit is contained in:
parent
5e458ac234
commit
cca0ab5d89
@ -53,12 +53,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// http://msdn2.microsoft.com/en-us/library/aa383022(VS.85).aspx
|
/// http://msdn2.microsoft.com/en-us/library/aa383022(VS.85).aspx
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private MsRdpClient9 rdpClient9 = null;
|
private MsRdpClient9 rdpClient = null;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This will be equal to rdpClient9
|
|
||||||
/// </summary>
|
|
||||||
private AxHost rdpControl = null;
|
|
||||||
|
|
||||||
public event EventHandler OnDisconnected = null;
|
public event EventHandler OnDisconnected = null;
|
||||||
|
|
||||||
@ -68,41 +63,39 @@ namespace XenAdmin.ConsoleView
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rdpControl = rdpClient9 = new MsRdpClient9();
|
rdpClient = new MsRdpClient9();
|
||||||
RDPConfigure(size);
|
RDPConfigure(size);
|
||||||
|
|
||||||
//add event handler for when RDP display is resized
|
//add event handler for when RDP display is resized
|
||||||
rdpClient9.OnRemoteDesktopSizeChange += rdpClient_OnRemoteDesktopSizeChange;
|
rdpClient.OnRemoteDesktopSizeChange += rdpClient_OnRemoteDesktopSizeChange;
|
||||||
|
rdpClient.Resize += resizeHandler;
|
||||||
// CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when
|
// CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when
|
||||||
// MsRdpClient9 control cannot be created (there is no appropriate version of dll present)
|
// MsRdpClient9 control cannot be created (there is no appropriate version of dll present)
|
||||||
parent.Controls.Add(rdpControl);
|
parent.Controls.Add(rdpClient);
|
||||||
allowDisplayUpdate = true;
|
allowDisplayUpdate = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (parent.Controls.Contains(rdpControl))
|
if (parent.Controls.Contains(rdpClient))
|
||||||
parent.Controls.Remove(rdpControl);
|
parent.Controls.Remove(rdpClient);
|
||||||
rdpControl.Dispose();
|
rdpClient.Dispose();
|
||||||
rdpControl = null;
|
rdpClient = null;
|
||||||
rdpClient9 = null;
|
|
||||||
Log.Error("Adding rdpControl to parent.Controls list caused an exception.", ex);
|
Log.Error("Adding rdpControl to parent.Controls list caused an exception.", ex);
|
||||||
}
|
}
|
||||||
rdpControl.Resize += resizeHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RDPConfigure(Size currentConsoleSize)
|
private void RDPConfigure(Size currentConsoleSize)
|
||||||
{
|
{
|
||||||
rdpControl.BeginInit();
|
rdpClient.BeginInit();
|
||||||
rdpLocationOffset = new Point(3, 3); //small offset to accomodate focus border
|
rdpLocationOffset = new Point(3, 3); //small offset to accomodate focus border
|
||||||
rdpControl.Dock = DockStyle.None;
|
rdpClient.Dock = DockStyle.None;
|
||||||
rdpControl.Anchor = AnchorStyles.None;
|
rdpClient.Anchor = AnchorStyles.None;
|
||||||
rdpControl.Size = currentConsoleSize;
|
rdpClient.Size = currentConsoleSize;
|
||||||
RDPAddOnDisconnected();
|
RDPAddOnDisconnected();
|
||||||
rdpControl.Enter += RdpEnter;
|
rdpClient.Enter += RdpEnter;
|
||||||
rdpControl.Leave += rdpClient_Leave;
|
rdpClient.Leave += rdpClient_Leave;
|
||||||
rdpControl.GotFocus += rdpClient_GotFocus;
|
rdpClient.GotFocus += rdpClient_GotFocus;
|
||||||
rdpControl.EndInit();
|
rdpClient.EndInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -110,52 +103,52 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rdpControl == null)
|
if (rdpClient == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rdpControl.Location = value;
|
rdpClient.Location = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RDPAddOnDisconnected()
|
private void RDPAddOnDisconnected()
|
||||||
{
|
{
|
||||||
if (rdpControl == null)
|
if (rdpClient == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rdpClient9.OnDisconnected += rdpClient_OnDisconnected;
|
rdpClient.OnDisconnected += rdpClient_OnDisconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RDPSetSettings()
|
private void RDPSetSettings()
|
||||||
{
|
{
|
||||||
if (rdpControl == null)
|
if (rdpClient == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rdpClient9.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0;
|
rdpClient.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0;
|
||||||
rdpClient9.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1;
|
rdpClient.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1;
|
||||||
rdpClient9.AdvancedSettings3.DisableRdpdr = Properties.Settings.Default.ClipboardAndPrinterRedirection ? 0 : 1;
|
rdpClient.AdvancedSettings3.DisableRdpdr = Properties.Settings.Default.ClipboardAndPrinterRedirection ? 0 : 1;
|
||||||
rdpClient9.AdvancedSettings7.ConnectToAdministerServer = Properties.Settings.Default.ConnectToServerConsole;
|
rdpClient.AdvancedSettings7.ConnectToAdministerServer = Properties.Settings.Default.ConnectToServerConsole;
|
||||||
|
|
||||||
//CA-103910 - enable NLA
|
//CA-103910 - enable NLA
|
||||||
rdpClient9.AdvancedSettings5.AuthenticationLevel = 2;
|
rdpClient.AdvancedSettings5.AuthenticationLevel = 2;
|
||||||
rdpClient9.AdvancedSettings7.EnableCredSspSupport = true;
|
rdpClient.AdvancedSettings7.EnableCredSspSupport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RDPConnect(string rdpIP, int w, int h)
|
public void RDPConnect(string rdpIP, int w, int h)
|
||||||
{
|
{
|
||||||
if (rdpControl == null)
|
if (rdpClient == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log.DebugFormat("Connecting RDPClient9 using server '{1}', width '{2}' and height '{3}'", rdpIP, w, h);
|
Log.DebugFormat("Connecting RDPClient9 using server '{0}', width '{1}' and height '{2}'", rdpIP, w, h);
|
||||||
|
|
||||||
rdpClient9.Server = rdpIP;
|
rdpClient.Server = rdpIP;
|
||||||
rdpClient9.DesktopWidth = w;
|
rdpClient.DesktopWidth = w;
|
||||||
rdpClient9.DesktopHeight = h;
|
rdpClient.DesktopHeight = h;
|
||||||
rdpClient9.Connect();
|
rdpClient.Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateDisplay(int width, int height, Point locationOffset)
|
public void UpdateDisplay(int width, int height, Point locationOffset)
|
||||||
{
|
{
|
||||||
if (rdpControl == null)
|
if (rdpClient == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Connected && allowDisplayUpdate)
|
if (Connected && allowDisplayUpdate)
|
||||||
@ -163,8 +156,8 @@ namespace XenAdmin.ConsoleView
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.DebugFormat("Updating display settings using width '{0}' and height '{1}'", width, height);
|
Log.DebugFormat("Updating display settings using width '{0}' and height '{1}'", width, height);
|
||||||
rdpClient9.UpdateSessionDisplaySettings((uint)width, (uint)height, (uint)width, (uint)height, 1, 1, 1);
|
rdpClient.UpdateSessionDisplaySettings((uint)width, (uint)height, (uint)width, (uint)height, 1, 1, 1);
|
||||||
rdpClient9.Size = new Size(width, height);
|
rdpClient.Size = new Size(width, height);
|
||||||
rdpLocationOffset = locationOffset;
|
rdpLocationOffset = locationOffset;
|
||||||
parent.AutoScroll = false;
|
parent.AutoScroll = false;
|
||||||
}
|
}
|
||||||
@ -172,24 +165,24 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
allowDisplayUpdate = false;
|
allowDisplayUpdate = false;
|
||||||
parent.AutoScroll = true;
|
parent.AutoScroll = true;
|
||||||
parent.AutoScrollMinSize = rdpClient9.Size;
|
parent.AutoScrollMinSize = rdpClient.Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Connected
|
private bool Connected
|
||||||
{
|
{
|
||||||
get { return rdpControl == null ? false : rdpClient9.Connected == 1; }
|
get { return rdpClient == null ? false : rdpClient.Connected == 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private int DesktopHeight
|
private int DesktopHeight
|
||||||
{
|
{
|
||||||
get { return rdpControl == null ? 0 : rdpClient9.DesktopHeight; }
|
get { return rdpClient == null ? 0 : rdpClient.DesktopHeight; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private int DesktopWidth
|
private int DesktopWidth
|
||||||
{
|
{
|
||||||
get { return rdpControl == null ? 0 : rdpClient9.DesktopWidth; }
|
get { return rdpClient == null ? 0 : rdpClient.DesktopWidth; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly List<System.Windows.Forms.Timer> RdpCleanupTimers = new List<System.Windows.Forms.Timer>();
|
private static readonly List<System.Windows.Forms.Timer> RdpCleanupTimers = new List<System.Windows.Forms.Timer>();
|
||||||
@ -207,10 +200,10 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
Program.AssertOnEventThread();
|
Program.AssertOnEventThread();
|
||||||
|
|
||||||
if (rdpControl == null || parent == null)
|
if (rdpClient == null || parent == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rdpControl.Size = DesktopSize;
|
rdpClient.Size = DesktopSize;
|
||||||
parent.Refresh();
|
parent.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,10 +215,10 @@ namespace XenAdmin.ConsoleView
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (parent.Controls.Contains(rdpControl))
|
if (parent.Controls.Contains(rdpClient))
|
||||||
parent.Controls.Remove(rdpControl);
|
parent.Controls.Remove(rdpClient);
|
||||||
rdpControl.Dispose();
|
rdpClient.Dispose();
|
||||||
rdpControl = null;
|
rdpClient = null;
|
||||||
Log.Error("Setting the RDP client properties caused an exception.", ex);
|
Log.Error("Setting the RDP client properties caused an exception.", ex);
|
||||||
}
|
}
|
||||||
RDPConnect(rdpIP, size.Width, size.Height);
|
RDPConnect(rdpIP, size.Width, size.Height);
|
||||||
@ -237,9 +230,9 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
if (Connected)
|
if (Connected)
|
||||||
{
|
{
|
||||||
if (rdpControl == null)
|
if (rdpClient == null)
|
||||||
return;
|
return;
|
||||||
rdpClient9.Disconnect();
|
rdpClient.Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(InvalidComObjectException ex)
|
catch(InvalidComObjectException ex)
|
||||||
@ -265,7 +258,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
bool containsFocus = parent.ParentForm != null && parent.ParentForm.ContainsFocus;
|
bool containsFocus = parent.ParentForm != null && parent.ParentForm.ContainsFocus;
|
||||||
|
|
||||||
if (rdpControl == null || !containsFocus)
|
if (rdpClient == null || !containsFocus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (KeyHandler.handleExtras<int>(pressed, pressedScans, KeyHandler.ExtraScans, scancode, KeyHandler.ModifierScans, ref modifierKeyPressedAlone))
|
if (KeyHandler.handleExtras<int>(pressed, pressedScans, KeyHandler.ExtraScans, scancode, KeyHandler.ModifierScans, ref modifierKeyPressedAlone))
|
||||||
@ -299,16 +292,16 @@ namespace XenAdmin.ConsoleView
|
|||||||
|
|
||||||
public Control ConsoleControl
|
public Control ConsoleControl
|
||||||
{
|
{
|
||||||
get { return rdpControl; }
|
get { return rdpClient; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate()
|
public void Activate()
|
||||||
{
|
{
|
||||||
Program.MainWindow.MenuShortcuts = false;
|
Program.MainWindow.MenuShortcuts = false;
|
||||||
if (rdpControl != null)
|
if (rdpClient != null)
|
||||||
{
|
{
|
||||||
if (!rdpControl.Focused)
|
if (!rdpClient.Focused)
|
||||||
rdpControl.Select();
|
rdpClient.Select();
|
||||||
|
|
||||||
InterceptKeys.releaseKeys();
|
InterceptKeys.releaseKeys();
|
||||||
InterceptKeys.grabKeys(new InterceptKeys.KeyEvent(handleRDPKey), true);
|
InterceptKeys.grabKeys(new InterceptKeys.KeyEvent(handleRDPKey), true);
|
||||||
@ -347,7 +340,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
if(disposing)
|
if(disposing)
|
||||||
{
|
{
|
||||||
if (rdpControl != null)
|
if (rdpClient != null)
|
||||||
{
|
{
|
||||||
// We need to dispose the rdp control. However, doing it immediately (in the control's own
|
// We need to dispose the rdp control. However, doing it immediately (in the control's own
|
||||||
// OnDisconnected event) will cause a horrible crash. Instead, start a timer that will
|
// OnDisconnected event) will cause a horrible crash. Instead, start a timer that will
|
||||||
@ -358,7 +351,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.Debug("RdpClient Dispose(): rdpControl.Dispose() in delegate");
|
Log.Debug("RdpClient Dispose(): rdpControl.Dispose() in delegate");
|
||||||
rdpControl.Dispose();
|
rdpClient.Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -376,7 +369,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
else
|
else
|
||||||
Log.Debug("RdpClient Dispose(): rdpControl == null");
|
Log.Debug("RdpClient Dispose(): rdpControl == null");
|
||||||
}
|
}
|
||||||
rdpControl = null;
|
rdpClient = null;
|
||||||
Log.Debug("RdpClient Dispose(): disposed = true");
|
Log.Debug("RdpClient Dispose(): disposed = true");
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
@ -417,7 +410,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
|
|
||||||
public Size DesktopSize
|
public Size DesktopSize
|
||||||
{
|
{
|
||||||
get { return rdpControl != null ? new Size(DesktopWidth, DesktopHeight) /*rdpControl.Size*/ : Size.Empty; }
|
get { return rdpClient != null ? new Size(DesktopWidth, DesktopHeight) /*rdpControl.Size*/ : Size.Empty; }
|
||||||
set { }
|
set { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +418,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return rdpControl != null ? new Rectangle(rdpControl.Location.X, rdpControl.Location.Y, DesktopWidth, DesktopHeight) : Rectangle.Empty;
|
return rdpClient != null ? new Rectangle(rdpClient.Location.X, rdpClient.Location.Y, DesktopWidth, DesktopHeight) : Rectangle.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user