From 5e458ac234c63eec71831c043132effd78c8943b Mon Sep 17 00:00:00 2001 From: Letsibogo Ramadi Date: Wed, 14 Jun 2017 17:22:42 +0100 Subject: [PATCH] CA-247333 - Remove rdpclient6 code after April 2017 when it will become redundant --- XenAdmin/ConsoleView/RdpClient.cs | 91 ++++++++++--------------------- XenAdmin/RDP/MsRdpClient6.cs | 50 ----------------- XenAdmin/XenAdmin.csproj | 3 - 3 files changed, 29 insertions(+), 115 deletions(-) delete mode 100644 XenAdmin/RDP/MsRdpClient6.cs diff --git a/XenAdmin/ConsoleView/RdpClient.cs b/XenAdmin/ConsoleView/RdpClient.cs index d85948be4..2ebeafaed 100644 --- a/XenAdmin/ConsoleView/RdpClient.cs +++ b/XenAdmin/ConsoleView/RdpClient.cs @@ -55,11 +55,8 @@ namespace XenAdmin.ConsoleView /// private MsRdpClient9 rdpClient9 = null; - private MsRdpClient6 rdpClient6 = null; - /// - /// This will be equal to rdpClient9, if the DLL that we've got is version 8, otherwise equal to - /// rdpClient6. + /// This will be equal to rdpClient9 /// private AxHost rdpControl = null; @@ -78,18 +75,18 @@ namespace XenAdmin.ConsoleView rdpClient9.OnRemoteDesktopSizeChange += rdpClient_OnRemoteDesktopSizeChange; // CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when - // MsRdpClient8 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); allowDisplayUpdate = true; } - catch + catch (Exception ex) { if (parent.Controls.Contains(rdpControl)) parent.Controls.Remove(rdpControl); + rdpControl.Dispose(); + rdpControl = null; rdpClient9 = null; - rdpControl = rdpClient6 = new MsRdpClient6(); - RDPConfigure(size); - parent.Controls.Add(rdpControl); + Log.Error("Adding rdpControl to parent.Controls list caused an exception.", ex); } rdpControl.Resize += resizeHandler; } @@ -97,7 +94,7 @@ namespace XenAdmin.ConsoleView private void RDPConfigure(Size currentConsoleSize) { rdpControl.BeginInit(); - rdpLocationOffset = new Point(3, 3); //small offset to accomodate focus rectangle + rdpLocationOffset = new Point(3, 3); //small offset to accomodate focus border rdpControl.Dock = DockStyle.None; rdpControl.Anchor = AnchorStyles.None; rdpControl.Size = currentConsoleSize; @@ -125,37 +122,22 @@ namespace XenAdmin.ConsoleView if (rdpControl == null) return; - if (rdpClient9 == null) - rdpClient6.OnDisconnected += rdpClient_OnDisconnected; - else - rdpClient9.OnDisconnected += rdpClient_OnDisconnected; + rdpClient9.OnDisconnected += rdpClient_OnDisconnected; } private void RDPSetSettings() { if (rdpControl == null) return; - - if (rdpClient9 == null) - { - rdpClient6.SecuredSettings2.KeyboardHookMode = Properties.Settings.Default.WindowsShortcuts ? 1 : 0; - rdpClient6.SecuredSettings2.AudioRedirectionMode = Properties.Settings.Default.ReceiveSoundFromRDP ? 0 : 1; - rdpClient6.AdvancedSettings3.DisableRdpdr = Properties.Settings.Default.ClipboardAndPrinterRedirection ? 0 : 1; - rdpClient6.AdvancedSettings7.ConnectToAdministerServer = Properties.Settings.Default.ConnectToServerConsole; - //CA-103910 - enable NLA - rdpClient6.AdvancedSettings5.AuthenticationLevel = 2; - rdpClient6.AdvancedSettings7.EnableCredSspSupport = true; - } - else - { - 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; - //CA-103910 - enable NLA - rdpClient9.AdvancedSettings5.AuthenticationLevel = 2; - rdpClient9.AdvancedSettings7.EnableCredSspSupport = true; - } + + 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; + + //CA-103910 - enable NLA + rdpClient9.AdvancedSettings5.AuthenticationLevel = 2; + rdpClient9.AdvancedSettings7.EnableCredSspSupport = true; } public void RDPConnect(string rdpIP, int w, int h) @@ -163,26 +145,12 @@ namespace XenAdmin.ConsoleView if (rdpControl == null) return; - Log.DebugFormat("Connecting RDPClient{0} using server '{1}', width '{2}' and height '{3}'", - rdpClient9 == null ? "6" : "9", - rdpIP, - w, - h); + Log.DebugFormat("Connecting RDPClient9 using server '{1}', width '{2}' and height '{3}'", rdpIP, w, h); - if (rdpClient9 == null) - { - rdpClient6.Server = rdpIP; - rdpClient6.DesktopWidth = w; - rdpClient6.DesktopHeight = h; - rdpClient6.Connect(); - } - else - { - rdpClient9.Server = rdpIP; - rdpClient9.DesktopWidth = w; - rdpClient9.DesktopHeight = h; - rdpClient9.Connect(); - } + rdpClient9.Server = rdpIP; + rdpClient9.DesktopWidth = w; + rdpClient9.DesktopHeight = h; + rdpClient9.Connect(); } public void UpdateDisplay(int width, int height, Point locationOffset) @@ -190,7 +158,7 @@ namespace XenAdmin.ConsoleView if (rdpControl == null) return; - if (Connected && rdpClient9 != null && allowDisplayUpdate) + if (Connected && allowDisplayUpdate) { try { @@ -211,17 +179,17 @@ namespace XenAdmin.ConsoleView private bool Connected { - get { return rdpControl == null ? false : (rdpClient9 == null ? rdpClient6.Connected == 1 : rdpClient9.Connected == 1); } + get { return rdpControl == null ? false : rdpClient9.Connected == 1; } } private int DesktopHeight { - get { return rdpControl == null ? 0 : (rdpClient9 == null ? rdpClient6.DesktopHeight : rdpClient9.DesktopHeight); } + get { return rdpControl == null ? 0 : rdpClient9.DesktopHeight; } } private int DesktopWidth { - get { return rdpControl == null ? 0 : (rdpClient9 == null ? rdpClient6.DesktopWidth : rdpClient9.DesktopWidth); } + get { return rdpControl == null ? 0 : rdpClient9.DesktopWidth; } } private static readonly List RdpCleanupTimers = new List(); @@ -269,10 +237,9 @@ namespace XenAdmin.ConsoleView { if (Connected) { - if (rdpClient9 == null) - rdpClient6.Disconnect(); - else - rdpClient9.Disconnect(); + if (rdpControl == null) + return; + rdpClient9.Disconnect(); } } catch(InvalidComObjectException ex) diff --git a/XenAdmin/RDP/MsRdpClient6.cs b/XenAdmin/RDP/MsRdpClient6.cs deleted file mode 100644 index d64d94d25..000000000 --- a/XenAdmin/RDP/MsRdpClient6.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, - * with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -namespace XenAdmin.RDP -{ - public class MsRdpClient6 : AxMSTSCLib.AxMsRdpClient6 - { - //Fix for the missing focus issue on the rdp client component - public MsRdpClient6() - : base() - { - } - - protected override void WndProc(ref System.Windows.Forms.Message m) - { - //Fix for the missing focus issue on the rdp client component - if (m.Msg == 0x0021) //WM_MOUSEACTIVATE ref:http://msdn.microsoft.com/en-us/library/ms645612(VS.85).aspx - this.Select(); - base.WndProc(ref m); - } - } -} \ No newline at end of file diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index 36f5c09b9..2b89065c8 100644 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -3020,9 +3020,6 @@ Component - - Component -