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>
|
||||
/// http://msdn2.microsoft.com/en-us/library/aa383022(VS.85).aspx
|
||||
/// </summary>
|
||||
private MsRdpClient9 rdpClient9 = null;
|
||||
|
||||
/// <summary>
|
||||
/// This will be equal to rdpClient9
|
||||
/// </summary>
|
||||
private AxHost rdpControl = null;
|
||||
private MsRdpClient9 rdpClient = null;
|
||||
|
||||
public event EventHandler OnDisconnected = null;
|
||||
|
||||
@ -68,41 +63,39 @@ namespace XenAdmin.ConsoleView
|
||||
this.size = size;
|
||||
try
|
||||
{
|
||||
rdpControl = rdpClient9 = new MsRdpClient9();
|
||||
rdpClient = new MsRdpClient9();
|
||||
RDPConfigure(size);
|
||||
|
||||
//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
|
||||
// MsRdpClient9 control cannot be created (there is no appropriate version of dll present)
|
||||
parent.Controls.Add(rdpControl);
|
||||
parent.Controls.Add(rdpClient);
|
||||
allowDisplayUpdate = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (parent.Controls.Contains(rdpControl))
|
||||
parent.Controls.Remove(rdpControl);
|
||||
rdpControl.Dispose();
|
||||
rdpControl = null;
|
||||
rdpClient9 = null;
|
||||
if (parent.Controls.Contains(rdpClient))
|
||||
parent.Controls.Remove(rdpClient);
|
||||
rdpClient.Dispose();
|
||||
rdpClient = null;
|
||||
Log.Error("Adding rdpControl to parent.Controls list caused an exception.", ex);
|
||||
}
|
||||
rdpControl.Resize += resizeHandler;
|
||||
}
|
||||
|
||||
private void RDPConfigure(Size currentConsoleSize)
|
||||
{
|
||||
rdpControl.BeginInit();
|
||||
rdpClient.BeginInit();
|
||||
rdpLocationOffset = new Point(3, 3); //small offset to accomodate focus border
|
||||
rdpControl.Dock = DockStyle.None;
|
||||
rdpControl.Anchor = AnchorStyles.None;
|
||||
rdpControl.Size = currentConsoleSize;
|
||||
rdpClient.Dock = DockStyle.None;
|
||||
rdpClient.Anchor = AnchorStyles.None;
|
||||
rdpClient.Size = currentConsoleSize;
|
||||
RDPAddOnDisconnected();
|
||||
rdpControl.Enter += RdpEnter;
|
||||
rdpControl.Leave += rdpClient_Leave;
|
||||
rdpControl.GotFocus += rdpClient_GotFocus;
|
||||
rdpControl.EndInit();
|
||||
rdpClient.Enter += RdpEnter;
|
||||
rdpClient.Leave += rdpClient_Leave;
|
||||
rdpClient.GotFocus += rdpClient_GotFocus;
|
||||
rdpClient.EndInit();
|
||||
}
|
||||
|
||||
|
||||
@ -110,52 +103,52 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
set
|
||||
{
|
||||
if (rdpControl == null)
|
||||
if (rdpClient == null)
|
||||
return;
|
||||
|
||||
rdpControl.Location = value;
|
||||
rdpClient.Location = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void RDPAddOnDisconnected()
|
||||
{
|
||||
if (rdpControl == null)
|
||||
if (rdpClient == null)
|
||||
return;
|
||||
|
||||
rdpClient9.OnDisconnected += rdpClient_OnDisconnected;
|
||||
rdpClient.OnDisconnected += rdpClient_OnDisconnected;
|
||||
}
|
||||
|
||||
private void RDPSetSettings()
|
||||
{
|
||||
if (rdpControl == null)
|
||||
if (rdpClient == null)
|
||||
return;
|
||||
|
||||
rdpClient9.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0;
|
||||
rdpClient9.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1;
|
||||
rdpClient9.AdvancedSettings3.DisableRdpdr = Properties.Settings.Default.ClipboardAndPrinterRedirection ? 0 : 1;
|
||||
rdpClient9.AdvancedSettings7.ConnectToAdministerServer = Properties.Settings.Default.ConnectToServerConsole;
|
||||
rdpClient.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0;
|
||||
rdpClient.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1;
|
||||
rdpClient.AdvancedSettings3.DisableRdpdr = Properties.Settings.Default.ClipboardAndPrinterRedirection ? 0 : 1;
|
||||
rdpClient.AdvancedSettings7.ConnectToAdministerServer = Properties.Settings.Default.ConnectToServerConsole;
|
||||
|
||||
//CA-103910 - enable NLA
|
||||
rdpClient9.AdvancedSettings5.AuthenticationLevel = 2;
|
||||
rdpClient9.AdvancedSettings7.EnableCredSspSupport = true;
|
||||
rdpClient.AdvancedSettings5.AuthenticationLevel = 2;
|
||||
rdpClient.AdvancedSettings7.EnableCredSspSupport = true;
|
||||
}
|
||||
|
||||
public void RDPConnect(string rdpIP, int w, int h)
|
||||
{
|
||||
if (rdpControl == null)
|
||||
if (rdpClient == null)
|
||||
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;
|
||||
rdpClient9.DesktopWidth = w;
|
||||
rdpClient9.DesktopHeight = h;
|
||||
rdpClient9.Connect();
|
||||
rdpClient.Server = rdpIP;
|
||||
rdpClient.DesktopWidth = w;
|
||||
rdpClient.DesktopHeight = h;
|
||||
rdpClient.Connect();
|
||||
}
|
||||
|
||||
public void UpdateDisplay(int width, int height, Point locationOffset)
|
||||
{
|
||||
if (rdpControl == null)
|
||||
if (rdpClient == null)
|
||||
return;
|
||||
|
||||
if (Connected && allowDisplayUpdate)
|
||||
@ -163,8 +156,8 @@ namespace XenAdmin.ConsoleView
|
||||
try
|
||||
{
|
||||
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);
|
||||
rdpClient9.Size = new Size(width, height);
|
||||
rdpClient.UpdateSessionDisplaySettings((uint)width, (uint)height, (uint)width, (uint)height, 1, 1, 1);
|
||||
rdpClient.Size = new Size(width, height);
|
||||
rdpLocationOffset = locationOffset;
|
||||
parent.AutoScroll = false;
|
||||
}
|
||||
@ -172,24 +165,24 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
allowDisplayUpdate = false;
|
||||
parent.AutoScroll = true;
|
||||
parent.AutoScrollMinSize = rdpClient9.Size;
|
||||
parent.AutoScrollMinSize = rdpClient.Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool Connected
|
||||
{
|
||||
get { return rdpControl == null ? false : rdpClient9.Connected == 1; }
|
||||
get { return rdpClient == null ? false : rdpClient.Connected == 1; }
|
||||
}
|
||||
|
||||
private int DesktopHeight
|
||||
{
|
||||
get { return rdpControl == null ? 0 : rdpClient9.DesktopHeight; }
|
||||
get { return rdpClient == null ? 0 : rdpClient.DesktopHeight; }
|
||||
}
|
||||
|
||||
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>();
|
||||
@ -207,10 +200,10 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
Program.AssertOnEventThread();
|
||||
|
||||
if (rdpControl == null || parent == null)
|
||||
if (rdpClient == null || parent == null)
|
||||
return;
|
||||
|
||||
rdpControl.Size = DesktopSize;
|
||||
rdpClient.Size = DesktopSize;
|
||||
parent.Refresh();
|
||||
}
|
||||
|
||||
@ -222,10 +215,10 @@ namespace XenAdmin.ConsoleView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (parent.Controls.Contains(rdpControl))
|
||||
parent.Controls.Remove(rdpControl);
|
||||
rdpControl.Dispose();
|
||||
rdpControl = null;
|
||||
if (parent.Controls.Contains(rdpClient))
|
||||
parent.Controls.Remove(rdpClient);
|
||||
rdpClient.Dispose();
|
||||
rdpClient = null;
|
||||
Log.Error("Setting the RDP client properties caused an exception.", ex);
|
||||
}
|
||||
RDPConnect(rdpIP, size.Width, size.Height);
|
||||
@ -237,9 +230,9 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
if (Connected)
|
||||
{
|
||||
if (rdpControl == null)
|
||||
if (rdpClient == null)
|
||||
return;
|
||||
rdpClient9.Disconnect();
|
||||
rdpClient.Disconnect();
|
||||
}
|
||||
}
|
||||
catch(InvalidComObjectException ex)
|
||||
@ -265,7 +258,7 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
bool containsFocus = parent.ParentForm != null && parent.ParentForm.ContainsFocus;
|
||||
|
||||
if (rdpControl == null || !containsFocus)
|
||||
if (rdpClient == null || !containsFocus)
|
||||
return;
|
||||
|
||||
if (KeyHandler.handleExtras<int>(pressed, pressedScans, KeyHandler.ExtraScans, scancode, KeyHandler.ModifierScans, ref modifierKeyPressedAlone))
|
||||
@ -299,16 +292,16 @@ namespace XenAdmin.ConsoleView
|
||||
|
||||
public Control ConsoleControl
|
||||
{
|
||||
get { return rdpControl; }
|
||||
get { return rdpClient; }
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
Program.MainWindow.MenuShortcuts = false;
|
||||
if (rdpControl != null)
|
||||
if (rdpClient != null)
|
||||
{
|
||||
if (!rdpControl.Focused)
|
||||
rdpControl.Select();
|
||||
if (!rdpClient.Focused)
|
||||
rdpClient.Select();
|
||||
|
||||
InterceptKeys.releaseKeys();
|
||||
InterceptKeys.grabKeys(new InterceptKeys.KeyEvent(handleRDPKey), true);
|
||||
@ -347,7 +340,7 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
if(disposing)
|
||||
{
|
||||
if (rdpControl != null)
|
||||
if (rdpClient != null)
|
||||
{
|
||||
// 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
|
||||
@ -358,7 +351,7 @@ namespace XenAdmin.ConsoleView
|
||||
try
|
||||
{
|
||||
Log.Debug("RdpClient Dispose(): rdpControl.Dispose() in delegate");
|
||||
rdpControl.Dispose();
|
||||
rdpClient.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -376,7 +369,7 @@ namespace XenAdmin.ConsoleView
|
||||
else
|
||||
Log.Debug("RdpClient Dispose(): rdpControl == null");
|
||||
}
|
||||
rdpControl = null;
|
||||
rdpClient = null;
|
||||
Log.Debug("RdpClient Dispose(): disposed = true");
|
||||
disposed = true;
|
||||
}
|
||||
@ -417,7 +410,7 @@ namespace XenAdmin.ConsoleView
|
||||
|
||||
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 { }
|
||||
}
|
||||
|
||||
@ -425,7 +418,7 @@ namespace XenAdmin.ConsoleView
|
||||
{
|
||||
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