Esempio n. 1
0
        public override void Connect()
        {
            string sel = "connectWithOptions:";

            RoyalRDSConnection rdpData = Data as RoyalRDSConnection;

            rdpData.BeginTemporaryMode();
            bool autologon = rdpData.CredentialAutologon;

            NSString hostname = rdpData.URI.ResolveTokensApi(rdpData).NS();
            int      port     = rdpData.RDPPort;

            rdpData.EndTemporaryMode();

            NSString username = NSString.Empty;
            //NSString domain = NSString.Empty;
            NSString password = NSString.Empty;

            rdpData.BeginTemporaryMode();
            CredentialInfo effectiveCred = rdpData.GetEffectiveCredential();

            rdpData.EndTemporaryMode();

            if (autologon && effectiveCred != null)
            {
                string usernameStr = effectiveCred.Username;
                string passwordStr = effectiveCred.Password;

                username = usernameStr.NS();
                password = passwordStr.NS();
            }

            int screenWidth  = 0;
            int screenHeight = 0;

            if (rdpData.DesktopWidth == 0 && rdpData.DesktopHeight == 0)
            {
                screenWidth  = (int)TabViewItem.View.CastTo <NSView>().Frame.Width;
                screenHeight = (int)TabViewItem.View.CastTo <NSView>().Frame.Height;
            }
            else
            {
                rdpData.BeginTemporaryMode();
                screenWidth  = rdpData.DesktopWidth;
                screenHeight = rdpData.DesktopHeight;
                rdpData.EndTemporaryMode();
            }

            // TODO: Screen Width should actually be a multitude of 4, not 8, but 8 seems to work just fine with rdesktop
            if (screenWidth % 8 != 0)
            {
                screenWidth = (screenWidth / 8) * 8;
            }

            m_screenWidth  = screenWidth;
            m_screenHeight = screenHeight;

            CordRdpOptions options = new CordRdpOptions();

            rdpData.BeginTemporaryMode();
            options.Hostname = hostname;
            options.Port     = port;
            options.Username = username;
            //options.Domain = domain;
            options.Password         = password;
            options.ConnectToConsole = rdpData.ConnectToAdministerOrConsole;
            options.SmartSize        = false;      //rdpData.SmartSizing;
            options.ScreenWidth      = screenWidth;
            options.ScreenHeight     = screenHeight;
            options.ColorDepth       = rdpData.ColorDepth;
            options.AllowWallpaper   = rdpData.AllowWallpaper;
            options.AllowAnimations  = rdpData.AllowMenuAnimations;
            options.FontSmoothing    = rdpData.AllowFontSmoothing;
            options.ShowWindowContentsWhileDragging = rdpData.AllowFullWindowDrag;
            options.ShowThemes           = rdpData.AllowThemes;
            options.RedirectPrinters     = rdpData.RedirectPrinters;
            options.RedirectDiskDrives   = rdpData.RedirectDrives;
            options.AudioRedirectionMode = rdpData.AudioRedirectionMode;
            rdpData.EndTemporaryMode();

            if (m_nativeController.RespondsToSelector(sel))
            {
                m_nativeController.SendMessage(sel, options);
            }

            options.Release();
        }