public TerminalItem(TerminalType type, string text)
 {
     _text = text;
     _type = type;
     switch (_type)
     {
         case TerminalType.Warning:
             _formatted = string.Format("<< {0}", text);
             _color = Terminal.Instance.WarningColor;
             break;
         case TerminalType.Error:
             _formatted = string.Format("<< {0}", text);
             _color = Terminal.Instance.ErrorColor;
             break;
         case TerminalType.Success:
             _formatted = string.Format("<< {0}", text);
             _color = Terminal.Instance.SuccessColor;
             break;
         case TerminalType.Important:
             _formatted = string.Format("<< {0}", text);
             _color = Terminal.Instance.ImportantColor;
             break;
         case TerminalType.Input:
             _formatted = string.Format(">> {0}", text);
             _color = Terminal.Instance.InputColor;
             break;
         default:
             _formatted = text;
             _color = Terminal.Instance.LogColor;
             break;
     }
 }
示例#2
0
 public ServerThread(string localAddress, int localPort, ConnectionType connectionType, TerminalType terminalType)
 {
     _LocalAddress = localAddress;
     _LocalPort = localPort;
     _ConnectionType = connectionType;
     _TerminalType = terminalType;
     _Paused = false;
 }
示例#3
0
        public Terminal(Airport airport, Airline airline, string name, int gates, DateTime deliveryDate, TerminalType type)
        {
            Airport = airport;
            Airline = airline;
            Name = name;
            DeliveryDate = new DateTime(deliveryDate.Year, deliveryDate.Month, deliveryDate.Day);
            Type = type;

            Gates = new Gates(gates, DeliveryDate, airline);
        }
示例#4
0
 public ITerminal CreateTerminal(TerminalType type)
 {
     switch (type)
     {
         case TerminalType.AlorTrade:
             return new AlorTerminal();
         case TerminalType.Oec:
             return new OecTerminal();
     }
     throw new InvalidOperationException();
 }
示例#5
0
    public bool Activate(TerminalType activationType)
    {
        if (terminalState == TerminalState.WaitingInput && !isActivated)
        {
            isActivated = true;
            activatedCorrectly = activationType == terminalType;
            boxCollider.enabled = false;
            ToggleButton(false);
            SetTerminalState(TerminalState.Accepted);
            Debug.Log(name + " activated correctly: " + activatedCorrectly);
            return true;
        }

        return false;
    }
示例#6
0
 //Listener以外を持ってくる
 public virtual void Import(ITerminalSettings src) {
     _encoding = src.Encoding;
     _terminalType = src.TerminalType;
     _localecho = src.LocalEcho;
     _lineFeedRule = src.LineFeedRule;
     _transmitnl = src.TransmitNL;
     _caption = src.Caption;
     _icon = src.Icon;
     TerminalSettings src_r = (TerminalSettings)src;
     _shellSchemeName = src_r._shellSchemeName; //ちょっとインチキ
     if (src_r._shellScheme != null) {
         _shellScheme = src_r._shellScheme;
         TerminalEmulatorPlugin.Instance.ShellSchemeCollection.AddDynamicChangeListener(this);
     }
     _enabledCharTriggerIntelliSense = src.EnabledCharTriggerIntelliSense;
     _renderProfile = src.RenderProfile == null ? null : (RenderProfile)src.RenderProfile.Clone();
     _multiLogSettings = src.LogSettings == null ? null : (IMultiLogSettings)_multiLogSettings.Clone();
 }
示例#7
0
        public TerminalSettings() {
            IPoderosaCulture culture = TerminalEmulatorPlugin.Instance.PoderosaWorld.Culture;
            if (culture.IsJapaneseOS || culture.IsSimplifiedChineseOS || culture.IsTraditionalChineseOS || culture.IsKoreanOS)
                _encoding = EncodingType.UTF8;
            else
                _encoding = EncodingType.ISO8859_1;

            _terminalType = TerminalType.XTerm;
            _localecho = false;
            _lineFeedRule = LineFeedRule.Normal;
            _transmitnl = NewLine.CR;
            _renderProfile = null;
            _shellSchemeName = ShellSchemeCollection.DEFAULT_SCHEME_NAME;
            _enabledCharTriggerIntelliSense = false;
            _multiLogSettings = new MultiLogSettings();

            _listeners = new ListenerList<ITerminalSettingsChangeListener>();
        }
示例#8
0
        public TerminalSettings()
        {
            IPoderosaCulture culture = TerminalEmulatorPlugin.Instance?.PoderosaWorld.Culture;

            if (culture == null || culture.IsJapaneseOS || culture.IsSimplifiedChineseOS || culture.IsTraditionalChineseOS || culture.IsKoreanOS)
            {
                _encoding = EncodingType.UTF8;
            }
            else
            {
                _encoding = EncodingType.ISO8859_1;
            }

            _terminalType    = TerminalType.XTerm;
            _localecho       = false;
            _lineFeedRule    = LineFeedRule.Normal;
            _transmitnl      = NewLine.CR;
            _renderProfile   = null;
            _shellSchemeName = ShellSchemeCollection.DEFAULT_SCHEME_NAME;
            _enabledCharTriggerIntelliSense = false;
            _multiLogSettings = new MultiLogSettings();

            _listeners = new ListenerList <ITerminalSettingsChangeListener>();
        }
示例#9
0
        private bool ValidateParams(out PipeTerminalParameter param, out PipeTerminalSettings settings)
        {
            PipeTerminalParameter paramTmp    = new PipeTerminalParameter();
            PipeTerminalSettings  settingsTmp = new PipeTerminalSettings();

            StringResource res = PipePlugin.Instance.Strings;

            try {
                string caption;

                if (_radioButtonProcess.Checked)
                {
                    string exePath = _textBoxExePath.Text;
                    if (exePath.Length == 0)
                    {
                        throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoExePath"));
                    }
                    paramTmp.ExeFilePath          = exePath;
                    paramTmp.CommandLineOptions   = _textBoxCommandLineOptions.Text;
                    paramTmp.EnvironmentVariables = _environmentVariables;
                    caption = Path.GetFileName(exePath);
                }
                else if (_radioButtonPipe.Checked)
                {
                    string path = _textBoxInputPath.Text;
                    if (path.Length == 0)
                    {
                        throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoInputPath"));
                    }
                    paramTmp.InputPipePath = path;
                    caption = Path.GetFileName(path);

                    if (!_checkBoxBidirectinal.Checked)
                    {
                        path = _textBoxOutputPath.Text;
                        if (path.Length == 0)
                        {
                            throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoOutputPath"));
                        }
                        paramTmp.OutputPipePath = path;
                        caption += "/" + Path.GetFileName(path);
                    }
                }
                else
                {
                    throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoOpenMode"));
                }

                TerminalType terminalType = ((EnumListItem <TerminalType>)_comboBoxTerminalType.SelectedItem).Value;
                paramTmp.SetTerminalName(terminalType.ToString().ToLowerInvariant());

                LogType            logType     = ((EnumListItem <LogType>)_comboBoxLogType.SelectedItem).Value;
                ISimpleLogSettings logSettings = null;
                if (logType != LogType.None)
                {
                    string             logFile = _textBoxLogFile.Text;
                    LogFileCheckResult r       = LogUtil.CheckLogFileName(logFile, this);
                    if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                    {
                        throw new Exception("");
                    }

                    logSettings           = PipePlugin.Instance.TerminalEmulatorService.CreateDefaultSimpleLogSettings();
                    logSettings.LogPath   = logFile;
                    logSettings.LogType   = logType;
                    logSettings.LogAppend = (r == LogFileCheckResult.Append);
                }

                string autoExecMacroPath = null;
                if (_textBoxAutoExecMacroPath.Text.Length != 0)
                {
                    autoExecMacroPath = _textBoxAutoExecMacroPath.Text;
                }

                IAutoExecMacroParameter autoExecParams = paramTmp.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                if (autoExecParams != null)
                {
                    autoExecParams.AutoExecMacroPath = autoExecMacroPath;
                }

                settingsTmp.BeginUpdate();
                settingsTmp.Caption      = caption;
                settingsTmp.Icon         = Poderosa.Pipe.Properties.Resources.Icon16x16;
                settingsTmp.Encoding     = ((EnumListItem <EncodingType>)_comboBoxEncoding.SelectedItem).Value;
                settingsTmp.LocalEcho    = _comboBoxLocalEcho.SelectedIndex == 1;
                settingsTmp.TransmitNL   = ((EnumListItem <NewLine>)_comboBoxNewLine.SelectedItem).Value;
                settingsTmp.TerminalType = terminalType;
                if (logSettings != null)
                {
                    settingsTmp.LogSettings.Reset(logSettings);
                }
                settingsTmp.EndUpdate();

                param    = paramTmp;
                settings = settingsTmp;
                return(true);
            }
            catch (Exception e) {
                if (e.Message.Length > 0)
                {
                    GUtil.Warning(this, e.Message);
                }
                param    = null;
                settings = null;
                return(false);
            }
        }
 protected _Integer(TerminalType type, int value) : base(type, value)
 {
 }
 protected _Integer64(TerminalType type, long value) : base(type, value)
 {
 }
示例#12
0
 internal void Import(TerminalParam r)
 {
     _encoding = r._encoding;
     _logtype = r._logtype;
     _logpath = r._logpath;
     _localecho = r._localecho;
     _transmitnl = r._transmitnl;
     _lineFeedRule = r._lineFeedRule;
     _terminalType = r._terminalType;
     _renderProfile = r._renderProfile==null? null : new RenderProfile(r._renderProfile);
     _caption = r._caption;
 }
示例#13
0
 public TerminalRegexTuple(TerminalType type, Regex regex)
 {
     this.type  = type;
     this.regex = regex;
 }
示例#14
0
 public ServerThread(string localAddress, int localPort, ConnectionType connectionType, TerminalType terminalType)
 {
     _LocalAddress   = localAddress;
     _LocalPort      = localPort;
     _ConnectionType = connectionType;
     _TerminalType   = terminalType;
     _Paused         = false;
 }
示例#15
0
        /// <summary>
        /// Validates input values and constructs parameter objects.
        /// </summary>
        /// <param name="loginParam">SSH parameter object is set when this method returns true.</param>
        /// <param name="terminalSettings">terminal settings object is set when this method returns true.</param>
        /// <param name="errorMessage">validation error message is set when this method returns false. this can be null when displaying error message is not needed.</param>
        /// <returns>true if all validations passed and parameter objects were created.</returns>
        private bool Validate(out ISSHLoginParameter loginParam, out ITerminalSettings terminalSettings, out string errorMessage)
        {
            loginParam       = null;
            terminalSettings = null;
            errorMessage     = null;

            var ssh = TerminalSessionsPlugin.Instance.ProtocolService.CreateDefaultSSHParameter();
            var tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));

            //--- SSH connection settings

            if (_ssh1RadioButton.Checked)
            {
                ssh.Method = SSHProtocol.SSH1;
            }
            else if (_ssh2RadioButton.Checked)
            {
                ssh.Method = SSHProtocol.SSH2;
            }
            else
            {
                errorMessage = TEnv.Strings.GetString("Message.LoginDialog.ProtocolVersionIsNotSpecified");
                return(false);
            }

            tcp.Destination = _hostBox.Text;
            if (String.IsNullOrEmpty(tcp.Destination))
            {
                errorMessage = TEnv.Strings.GetString("Message.LoginDialog.HostIsEmpty");
                return(false);
            }

            int port;

            if (Int32.TryParse(_portBox.Text, out port) && port >= 0 && port <= 65535)
            {
                tcp.Port = port;
            }
            else
            {
                errorMessage = String.Format(
                    TEnv.Strings.GetString("Message.LoginDialog.InvalidPort"),
                    _portBox.Text);
                return(false);
            }

            ssh.Account = _userNameBox.Text;

            AuthType authType = ((EnumListItem <AuthType>)_authOptions.SelectedItem).Value;

            ssh.AuthenticationType = authType.ToAuthenticationType();

            if (ssh.AuthenticationType == AuthenticationType.PublicKey)
            {
                ssh.IdentityFileName = _privateKeyFile.Text;

                if (String.IsNullOrEmpty(ssh.IdentityFileName))
                {
                    errorMessage = TEnv.Strings.GetString("Message.LoginDialog.PrivateKeyFileIsNotSpecified");
                    return(false);
                }

                if (!File.Exists(ssh.IdentityFileName))
                {
                    errorMessage = TEnv.Strings.GetString("Message.LoginDialog.KeyFileNotExist");
                    return(false);
                }
            }

            if (ssh.AuthenticationType == AuthenticationType.Password || ssh.AuthenticationType == AuthenticationType.PublicKey)
            {
                ssh.PasswordOrPassphrase = _passphraseBox.Text;
            }

            //--- Log settings

            ISimpleLogSettings logSettings = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultSimpleLogSettings();

            logSettings.LogType = ((EnumListItem <LogType>)_logTypeBox.SelectedItem).Value;
            if (logSettings.LogType != LogType.None)
            {
                logSettings.LogPath = _logFileBox.Text;
                LogFileCheckResult r = LogUtil.CheckLogFileName(logSettings.LogPath, this.ParentForm);
                if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                {
                    errorMessage = null;
                    return(false);
                }
                logSettings.LogAppend = (r == LogFileCheckResult.Append);
            }

            //--- Terminal settings

            ITerminalParameter termParam    = (ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter));
            TerminalType       terminalType = ((EnumListItem <TerminalType>)_terminalTypeBox.SelectedItem).Value;

            termParam.SetTerminalName(terminalType.ToTermValue());

            string            terminalCaption = tcp.Destination;
            Image             terminalIcon    = Poderosa.TerminalSession.Properties.Resources.NewConnection16x16;
            ITerminalSettings termSettings    = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings(terminalCaption, terminalIcon);

            termSettings.BeginUpdate();
            termSettings.Encoding     = ((EnumListItem <EncodingType>)_encodingBox.SelectedItem).Value;
            termSettings.LocalEcho    = ((ListItem <bool>)_localEchoBox.SelectedItem).Value;
            termSettings.TransmitNL   = ((EnumListItem <NewLine>)_newLineBox.SelectedItem).Value;
            termSettings.TerminalType = terminalType;
            termSettings.LogSettings.Reset(logSettings);
            termSettings.EndUpdate();

            //--- X11 forwarding settings

            if (_useX11ForwardingCheckBox.Checked)
            {
                if (String.IsNullOrEmpty(_x11DisplayText.Text))
                {
                    errorMessage = TEnv.Strings.GetString("Message.LoginDialog.X11DisplayIsNotEntered");
                    return(false);
                }
                int display;
                if (!Int32.TryParse(_x11DisplayText.Text, out display) || display < 0 || display > (65535 - 6000))
                {
                    errorMessage = TEnv.Strings.GetString("Message.LoginDialog.InvalidX11Display");
                    return(false);
                }

                X11ForwardingParams x11Param = new X11ForwardingParams(display);

                if (String.IsNullOrEmpty(_x11ScreenText.Text))
                {
                    errorMessage = TEnv.Strings.GetString("Message.LoginDialog.X11ScreenIsNotEntered");
                    return(false);
                }
                int screen;
                if (!Int32.TryParse(_x11ScreenText.Text, out screen) || screen < 0)
                {
                    errorMessage = TEnv.Strings.GetString("Message.LoginDialog.InvalidX11Screen");
                    return(false);
                }
                x11Param.Screen = screen;

                if (_x11NeedAuthCheckBox.Checked)
                {
                    x11Param.NeedAuth       = true;
                    x11Param.XauthorityFile = _x11XauthorityText.Text;
                    if (String.IsNullOrEmpty(x11Param.XauthorityFile))
                    {
                        errorMessage = TEnv.Strings.GetString("Message.LoginDialog.XauthorityFileIsNotSpecified");
                        return(false);
                    }
                }
                else
                {
                    x11Param.NeedAuth = false;
                }

                if (_x11UseCygwinDomainSocketCheckBox.Checked)
                {
                    x11Param.UseCygwinUnixDomainSocket = true;
                    x11Param.X11UnixFolder             = _x11CygwinX11UnixFolderText.Text;
                    if (String.IsNullOrEmpty(x11Param.X11UnixFolder))
                    {
                        errorMessage = TEnv.Strings.GetString("Message.LoginDialog.X11UnixFolderIsNotSpecified");
                        return(false);
                    }
                }

                ssh.EnableX11Forwarding = true;
                ssh.X11Forwarding       = x11Param;
            }
            else
            {
                ssh.EnableX11Forwarding = false;
                ssh.X11Forwarding       = null;
            }

            //--- Agent forwarding settings

            if (_useAgentForwardingCheckBox.Checked)
            {
                ssh.EnableAgentForwarding          = true;
                ssh.AgentForwardingAuthKeyProvider = null;  // set later
            }
            else
            {
                ssh.EnableAgentForwarding          = false;
                ssh.AgentForwardingAuthKeyProvider = null;
            }

            //--- Macro

            IAutoExecMacroParameter autoExecParams = tcp.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;

            if (autoExecParams != null)     // macro plugin is enabled
            {
                if (!String.IsNullOrEmpty(_autoExecMacroPathBox.Text))
                {
                    autoExecParams.AutoExecMacroPath = _autoExecMacroPathBox.Text;
                }
                else
                {
                    autoExecParams.AutoExecMacroPath = null;
                }
            }

            loginParam       = ssh;
            terminalSettings = termSettings;
            return(true);
        }
示例#16
0
        /// <summary>
        /// Validates input values and constructs parameter objects.
        /// </summary>
        /// <param name="telnetParam">Telnet parameter object is set when this method returns true.</param>
        /// <param name="terminalSettings">terminal settings object is set when this method returns true.</param>
        /// <param name="errorMessage">validation error message is set when this method returns false. this can be null when displaying error message is not needed.</param>
        /// <returns>true if all validations passed and parameter objects were created.</returns>
        private bool Validate(out ITCPParameter telnetParam, out ITerminalSettings terminalSettings, out string errorMessage)
        {
            telnetParam      = null;
            terminalSettings = null;
            errorMessage     = null;

            var telnet        = TerminalSessionsPlugin.Instance.ProtocolService.CreateDefaultTelnetParameter();
            var tcp           = (ITCPParameter)telnet.GetAdapter(typeof(ITCPParameter));
            var protocolParam = (ITelnetParameter)telnet.GetAdapter(typeof(ITelnetParameter));

            tcp.Destination = _hostBox.Text;
            if (String.IsNullOrEmpty(tcp.Destination))
            {
                errorMessage = TEnv.Strings.GetString("Message.LoginDialog.HostIsEmpty");
                return(false);
            }

            int port;

            if (Int32.TryParse(_portBox.Text, out port) && port >= 0 && port <= 65535)
            {
                tcp.Port = port;
            }
            else
            {
                errorMessage = String.Format(
                    TEnv.Strings.GetString("Message.LoginDialog.InvalidPort"),
                    _portBox.Text);
                return(false);
            }

            //--- Log settings

            ISimpleLogSettings logSettings = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultSimpleLogSettings();

            logSettings.LogType = ((EnumListItem <LogType>)_logTypeBox.SelectedItem).Value;
            if (logSettings.LogType != LogType.None)
            {
                logSettings.LogPath = _logFileBox.Text;
                LogFileCheckResult r = LogUtil.CheckLogFileName(logSettings.LogPath, this.ParentForm);
                if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                {
                    errorMessage = null;
                    return(false);
                }
                logSettings.LogAppend = (r == LogFileCheckResult.Append);
            }

            //--- Terminal settings

            ITerminalParameter termParam    = (ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter));
            TerminalType       terminalType = ((EnumListItem <TerminalType>)_terminalTypeBox.SelectedItem).Value;

            termParam.SetTerminalName(terminalType.ToTermValue());

            string            terminalCaption = tcp.Destination;
            Image             terminalIcon    = Poderosa.TerminalSession.Properties.Resources.NewConnection16x16;
            ITerminalSettings termSettings    = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings(terminalCaption, terminalIcon);

            termSettings.BeginUpdate();
            termSettings.Encoding     = ((EnumListItem <EncodingType>)_encodingBox.SelectedItem).Value;
            termSettings.LocalEcho    = ((ListItem <bool>)_localEchoBox.SelectedItem).Value;
            termSettings.TransmitNL   = ((EnumListItem <NewLine>)_newLineBox.SelectedItem).Value;
            termSettings.TerminalType = terminalType;
            termSettings.LogSettings.Reset(logSettings);
            termSettings.EndUpdate();

            //--- TELNET protocol settings

            protocolParam.TelnetNewLine =
                (termSettings.TransmitNL == NewLine.CRLF) ? _telnetNewLine.Checked : false;

            //--- Macro

            IAutoExecMacroParameter autoExecParams = tcp.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;

            if (autoExecParams != null)     // macro plugin is enabled
            {
                if (!String.IsNullOrEmpty(_autoExecMacroPathBox.Text))
                {
                    autoExecParams.AutoExecMacroPath = _autoExecMacroPathBox.Text;
                }
                else
                {
                    autoExecParams.AutoExecMacroPath = null;
                }
            }

            telnetParam      = tcp;
            terminalSettings = termSettings;
            return(true);
        }
示例#17
0
        //入力内容に誤りがあればそれを警告してnullを返す。なければ必要なところを埋めたTCPTerminalParamを返す
        private ITerminalParameter ValidateContent()
        {
            string             msg = null;
            ITCPParameter      tcp = null;
            ISSHLoginParameter ssh = null;

            try {
                ConnectionMethod m = ParseMethod(_methodBox.Text);
                if (m == ConnectionMethod.Telnet)
                {
                    tcp = TerminalSessionsPlugin.Instance.ProtocolService.CreateDefaultTelnetParameter();
                }
                else
                {
                    ISSHLoginParameter sp = TerminalSessionsPlugin.Instance.ProtocolService.CreateDefaultSSHParameter();
                    tcp         = (ITCPParameter)sp.GetAdapter(typeof(ITCPParameter));
                    ssh         = sp;
                    ssh.Method  = m == ConnectionMethod.SSH1? SSHProtocol.SSH1 : SSHProtocol.SSH2;
                    ssh.Account = _userNameBox.Text;
                    ssh.PasswordOrPassphrase = _passphraseBox.Text;
                }

                tcp.Destination = _hostBox.Text;
                try {
                    tcp.Port = ParsePort(_portBox.Text);
                }
                catch (FormatException ex) {
                    msg = ex.Message;
                }

                if (_hostBox.Text.Length == 0)
                {
                    msg = TEnv.Strings.GetString("Message.LoginDialog.HostIsEmpty");
                }

                //ログ設定
                LogType            logtype     = (LogType)EnumDescAttribute.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);
                ISimpleLogSettings logsettings = null;
                if (logtype != LogType.None)
                {
                    logsettings = CreateSimpleLogSettings(logtype, _logFileBox.Text);
                    if (logsettings == null)
                    {
                        return(null);                  //動作キャンセル
                    }
                }

                ITerminalParameter param         = (ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter));
                TerminalType       terminal_type = (TerminalType)_terminalTypeBox.SelectedIndex;
                param.SetTerminalName(ToTerminalName(terminal_type));

                if (ssh != null)
                {
                    Debug.Assert(ssh != null);
                    ssh.AuthenticationType = ToAuthenticationType(_authOptions.SelectedIndex);
                    if (ssh.AuthenticationType == AuthenticationType.PublicKey)
                    {
                        if (!File.Exists(_privateKeyFile.Text))
                        {
                            msg = TEnv.Strings.GetString("Message.LoginDialog.KeyFileNotExist");
                        }
                        else
                        {
                            ssh.IdentityFileName = _privateKeyFile.Text;
                        }
                    }
                }

                string autoExecMacroPath = null;
                if (_autoExecMacroPathBox.Text.Length != 0)
                {
                    autoExecMacroPath = _autoExecMacroPathBox.Text;
                }

                IAutoExecMacroParameter autoExecParams = tcp.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                if (autoExecParams != null)
                {
                    autoExecParams.AutoExecMacroPath = autoExecMacroPath;
                }

                ITerminalSettings settings = this.TerminalSettings;
                settings.BeginUpdate();
                settings.Caption      = _hostBox.Text;
                settings.Icon         = Poderosa.TerminalSession.Properties.Resources.NewConnection16x16;
                settings.Encoding     = (EncodingType)_encodingBox.SelectedIndex;
                settings.LocalEcho    = _localEchoBox.SelectedIndex == 1;
                settings.TransmitNL   = (NewLine)EnumDescAttribute.For(typeof(NewLine)).FromDescription(_newLineBox.Text, NewLine.CR);
                settings.TerminalType = terminal_type;
                if (logsettings != null)
                {
                    settings.LogSettings.Reset(logsettings);
                }
                settings.EndUpdate();

                if (msg != null)
                {
                    ShowError(msg);
                    return(null);
                }
                else
                {
                    return((ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter)));
                }
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(null);
            }
        }
示例#18
0
文件: DbTerminal.cs 项目: radtek/Pos
        public static void UpdateTerminal(string terminalIpAddress, string displayName, TerminalType terminalType, int terminalKey)
        {
            var whereCondition = " Where TERMINALID=@TERMINALID";
            var fbParameters   = new List <QueryParameter>();

            fbParameters.Add(new QueryParameter("TERMINALIPADDRESS", terminalIpAddress));
            fbParameters.Add(new QueryParameter("DISPLAY_NAME", displayName));
            fbParameters.Add(new QueryParameter("TERMINAL_TYPE", terminalType));
            var commandText = DatabaseCore.Instance.BuildUpdateQuery("TERMINALS", fbParameters, whereCondition);

            fbParameters.Add(new QueryParameter("TERMINALID", terminalKey));
            DatabaseCore.Instance.ExecuteNonQuery(commandText, fbParameters);
        }
示例#19
0
    /// <summary>
    /// オーナーのコネクションアクション
    /// </summary>
    public void OnOwnerConnection()
    {
        if (PhotonNetwork.isMasterClient) return;

        StartCoroutine("OnConnection");
        type = TerminalType.Owner;
    }
示例#20
0
        public ITerminalParameter PrepareTerminalParameter(string UserName, string Pwd, string DestHost, int Port, ConnectionMethod m, string PublicKeyFile, LogType logType, string logPath)
        {
            string msg = null;

            if (_terminalOptions == null)
            {
                _terminalOptions = new TerminalOptions("");
            }
            if (_terminalSettings == null)
            {
                _terminalSettings = new TerminalSettings();
            }

            try
            {
                if (Port == 0)
                {
                    if (m == ConnectionMethod.Telnet)
                    {
                        Port = 23;
                    }
                    else
                    {
                        Port = 22;
                    }
                }

                tcp             = _Console.CreateDefaultTelnetParameter();
                tcp.Destination = DestHost;
                tcp.Port        = Port;
                if (m == ConnectionMethod.SSH1 || (m == ConnectionMethod.SSH2))
                {
                    SSHLoginParameter sp = _Console.CreateDefaultSSHParameter();
                    ssh                      = sp;
                    ssh.Destination          = DestHost;
                    ssh.Port                 = Port;
                    ssh.Method               = m == ConnectionMethod.SSH1 ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
                    ssh.Account              = UserName;
                    ssh.PasswordOrPassphrase = Pwd;
                }

                if (DestHost.Length == 0)
                {
                    msg = "Message.TelnetSSHLogin.HostIsEmpty";
                }

                //ƒƒOÝ’è
                ISimpleLogSettings logsettings = null;
                if (logType != LogType.None)
                {
                    if (logPath.Length == 0)
                    {
                        logPath = AppDomain.CurrentDomain.BaseDirectory;// +DestHost;
                    }
                    logsettings         = new SimpleLogSettings();
                    logsettings.LogPath = logPath;
                    logsettings.LogType = logType;
                    LogFileCheckResult r = LogUtil.CheckLogFileName(logPath);
                    if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                    {
                        return(null);
                    }
                    logsettings.LogAppend = (r == LogFileCheckResult.Append);
                    if (logsettings == null)
                    {
                        return(null); //“®ìƒLƒƒƒ“ƒZƒ‹
                    }
                    _terminalOptions.DefaultLogType      = logType;
                    _terminalOptions.DefaultLogDirectory = logPath;
                }

                _param = (ITerminalParameter)tcp; //(ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter));
                TerminalType terminal_type = TerminalType.VT100;
                _param.SetTerminalName(ToTerminalName(terminal_type));

                if (ssh != null)
                {
                    Debug.Assert(ssh != null);
                    if (PublicKeyFile.Length > 0)
                    {
                        ssh.AuthenticationType = AuthenticationType.PublicKey;
                        if (!File.Exists(PublicKeyFile))
                        {
                            msg = "Message.TelnetSSHLogin.KeyFileNotExist";
                        }
                        else
                        {
                            ssh.IdentityFileName = PublicKeyFile;
                        }
                    }
                }

                ITerminalSettings settings = this.TerminalSettings;
                settings.BeginUpdate();
                settings.Caption = DestHost;
                //settings.Icon = IconList.LoadIcon(IconList.ICON_NEWCONNECTION);
                settings.Encoding     = EncodingType.ISO8859_1;
                settings.LocalEcho    = false;
                settings.TransmitNL   = NewLine.CRLF; // .LF; //.CR;
                settings.LineFeedRule = ConnectionParam.LineFeedRule.Normal;
                settings.TerminalType = terminal_type;
                settings.DebugFlag    = _debug;
                if (logsettings != null)
                {
                    settings.LogSettings.Reset(logsettings);
                }
                settings.EndUpdate();

                if (msg != null)
                {
                    if (_debug > 0) //ShowError(msg);
                    {
                        Console.WriteLine(msg);
                    }
                    return(null);
                }
                else
                {
                    return((ITerminalParameter)tcp); //.GetAdapter(typeof(ITerminalParameter));
                }
            }
            catch (Exception ex)
            {
                if (_debug > 0)
                {
                    Console.WriteLine(ex.Message);
                }
                return(null);
            }
        }
 /// <summary>
 /// write only
 /// </summary>
 public static void Add(object message, TerminalType type)
 {
     Add(new TerminalItem(type, message.ToString()));
 }
示例#22
0
        /// <summary>
        /// 将终结符号的枚举转换为字符串
        /// </summary>
        /// <param name="T">终结符号枚举</param>
        /// <returns>对应的字符串</returns>
        public string T2String(TerminalType T)
        {
            string resultString;

            switch (T)
            {
            case TerminalType.IF:
                resultString = "if";
                break;

            case TerminalType.ELSE:
                resultString = "else";
                break;

            case TerminalType.WHILE:
                resultString = "while";
                break;

            case TerminalType.READ:
                resultString = "read";
                break;

            case TerminalType.WRITE:
                resultString = "write";
                break;

            case TerminalType.INT:
                resultString = "int";
                break;

            case TerminalType.REAL:
                resultString = "real";
                break;

            case TerminalType.PLUS:
                resultString = "+";
                break;

            case TerminalType.MINUS:
                resultString = "-";
                break;

            case TerminalType.MUL:
                resultString = "*";
                break;

            case TerminalType.DIV:
                resultString = "/";
                break;

            case TerminalType.ASSIGN:
                resultString = "=";
                break;

            case TerminalType.LESS:
                resultString = "<";
                break;

            case TerminalType.GREATER:
                resultString = ">";
                break;

            case TerminalType.EQUAL:
                resultString = "==";
                break;

            case TerminalType.NOTEQUAL:
                resultString = "<>";
                break;

            case TerminalType.LPARENT:
                resultString = "(";
                break;

            case TerminalType.RPARENT:
                resultString = ")";
                break;

            case TerminalType.SEMI:
                resultString = ";";
                break;

            case TerminalType.LBRACE:
                resultString = "{";
                break;

            case TerminalType.RBRACE:
                resultString = "}";
                break;

            case TerminalType.NOTES:
                resultString = "/**/";
                break;

            case TerminalType.LBRACKET:
                resultString = "[";
                break;

            case TerminalType.RBRACKET:
                resultString = "]";
                break;

            case TerminalType.COMMA:
                resultString = ",";
                break;

            case TerminalType.INTVAL:
                resultString = "整数类型的值";
                break;

            case TerminalType.REALVAL:
                resultString = "浮点类型的值";
                break;

            case TerminalType.ID:
                resultString = "标识符";
                break;

            case TerminalType.ERR:
                resultString = "错误信息";
                break;

            case TerminalType.END:
                resultString = "程序结束标志";
                break;

            case TerminalType.EMPTY:
                resultString = "'空'";
                break;

            case TerminalType.BREAKPOINT:
                resultString = "断点";
                break;

            case TerminalType.DEFAULT:
                resultString = "默认终结符号";
                break;

            default:
                resultString = "";
                break;
            }
            return(resultString);
        }
示例#23
0
 /// <summary>
 /// 利用非终结符号和终结符号获取预测分析表的表项(产生式)
 /// </summary>
 /// <param name="nEnum"></param>
 /// <param name="tokenType"></param>
 /// <returns></returns>
 public List <ParsingTableItem> GetItem(NEnum nEnum, TerminalType tokenType)
 {
     return(this.parsingTable[(int)nEnum, (int)tokenType]);
 }
 public RootTerminal(Point position, TerminalType type)
 {
     this.position = position;
     this.type     = type;
 }
示例#25
0
 public Terminal(TerminalType type, string value)
 {
     this.type  = type;
     this.value = value;
 }
示例#26
0
        /// <summary>
        /// 分析特殊符号开头的单词
        /// </summary>
        static void AnalyseSymbol()
        {
            switch (ch)
            {
            case '=':
                if (Peek() == '=')
                {
                    value = TerminalType.EQUAL;
                    Concat();
                }
                else
                {
                    Retract();
                    value = TerminalType.ASSIGN;
                }
                break;

            case '<':
                if (Peek() == '>')
                {
                    value = TerminalType.NOTEQUAL;
                    Concat();
                }
                else
                {
                    Retract();
                    value = TerminalType.LESS;
                }
                break;

            case '/':
                if (Peek() == '*')
                {
                    buffer = "";
                    value  = TerminalType.NOTES;
                    Read();
                    //跳过注释
                    while (Peek() != '*' || Peek() != '/')
                    {
                        AnalyseRow();
                        if (ch == '\0')
                        {
                            throw new Exception("注释错误:缺少注释结尾");
                        }
                    }
                    return;
                }
                else if (ch == '/')
                {
                    buffer = "";
                    value  = TerminalType.NOTES;
                    Read();
                    //跳过注释
                    while (Peek() != '\r' && Peek() != '\n' && ch != '\0')
                    {
                        ;
                    }
                    return;
                }
                else
                {
                    Retract();
                    value = TerminalType.DIV;
                }
                break;

            case '+':
                value = TerminalType.PLUS;
                break;

            case '-':
                value = TerminalType.MINUS;
                break;

            case '*':
                value = TerminalType.MUL;
                break;

            case '>':
                value = TerminalType.GREATER;
                break;

            case '(':
                value = TerminalType.LPARENT;
                break;

            case ')':
                value = TerminalType.RPARENT;
                break;

            case ';':
                value = TerminalType.SEMI;
                break;

            case '{':
                value = TerminalType.LBRACE;
                break;

            case '}':
                value = TerminalType.RBRACE;
                break;

            case '[':
                value = TerminalType.LBRACKET;
                break;

            case ']':
                value = TerminalType.RBRACKET;
                break;

            case ',':
                value = TerminalType.COMMA;
                break;

            default:
                throw new Exception("符号错误:未知符号");
            }
            Read();
        }
示例#27
0
 public static string ToTerminalName(TerminalType tt) {
     switch (tt) {
         case TerminalType.KTerm:
             return "kterm";
         case TerminalType.XTerm:
             return "xterm";
         default:
             return "vt100";
     }
 }
示例#28
0
 public Terminal(Airport airport, string name, int gates, DateTime deliveryDate, TerminalType type)
     : this(airport, null, name, gates, deliveryDate, type)
 {
 }
示例#29
0
    /// <summary>
    /// ウォッチのコネクションアクション
    /// </summary>
    public void OnWatchConnection()
    {
        if (!PhotonNetwork.isMasterClient) return;

        StartCoroutine("OnConnection");
        type = TerminalType.Watch;
    }
示例#30
0
        protected override void Execute()
        {
            using (TcpConnection Connection = new TcpConnection())
            {
                if (Connection.Listen(_LocalAddress, _LocalPort))
                {
                    RaiseBoundEvent();

                    while (!_Stop)
                    {
                        // Accept an incoming connection
                        if (Connection.CanAccept(1000)) // 1 second
                        {
                            try
                            {
                                TcpConnection NewConnection = Connection.AcceptTCP();
                                if (NewConnection != null)
                                {
                                    TcpConnection TypedConnection = null;
                                    switch (_ConnectionType)
                                    {
                                    case ConnectionType.RLogin:
                                        TypedConnection = new RLoginConnection();
                                        break;

                                    case ConnectionType.Telnet:
                                        TypedConnection = new TelnetConnection();
                                        break;

                                    case ConnectionType.WebSocket:
                                        TypedConnection = new WebSocketConnection();
                                        break;
                                    }
                                    if (TypedConnection != null)
                                    {
                                        TypedConnection.Open(NewConnection.GetSocket());

                                        if (IsIgnoredIP(TypedConnection.GetRemoteIP()))
                                        {
                                            // Do nothing for ignored IPs
                                            TypedConnection.Close();
                                        }
                                        else
                                        {
                                            RaiseMessageEvent("Incoming " + _ConnectionType.ToString() + " connection from " + TypedConnection.GetRemoteIP() + ":" + TypedConnection.GetRemotePort());

                                            TerminalType TT = GetTerminalType(TypedConnection);
                                            if (IsBannedIP(TypedConnection.GetRemoteIP()))
                                            {
                                                DisplayAnsi("IP_BANNED", TypedConnection, TT);
                                                RaiseWarningMessageEvent("IP " + TypedConnection.GetRemoteIP() + " matches banned IP filter");
                                                TypedConnection.Close();
                                            }
                                            else if (_Paused)
                                            {
                                                DisplayAnsi("SERVER_PAUSED", TypedConnection, TT);
                                                TypedConnection.Close();
                                            }
                                            else
                                            {
                                                if (!TypedConnection.Connected)
                                                {
                                                    RaiseMessageEvent("No carrier detected (maybe it was a 'ping'?)");
                                                    TypedConnection.Close();
                                                }
                                                else
                                                {
                                                    ClientThread NewClientThread = new ClientThread();
                                                    int          NewNode         = RaiseConnectEvent(ref NewClientThread);
                                                    if (NewNode == 0)
                                                    {
                                                        NewClientThread.Dispose();
                                                        DisplayAnsi("SERVER_BUSY", TypedConnection, TT);
                                                        TypedConnection.Close();
                                                    }
                                                    else
                                                    {
                                                        NewClientThread.Start(NewNode, TypedConnection, _ConnectionType, TT);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                RaiseExceptionEvent("Error in ServerThread::Execute()", ex);
                            }
                        }
                    }
                }
                else
                {
                    RaiseErrorMessageEvent("Server Thread unable to listen on " + _LocalAddress + ":" + _LocalPort);
                    RaiseBindFailedEvent();
                }
            }
        }
示例#31
0
        public ActionResult SearchPaymentTerminals(string sidx, string sord, int page, int rows, string uuid, TerminalType terminalType)
        {
            var paymentService = new PaymentService(AuthenticatedUser.SessionToken);
            var filters        = new List <FilterModel>();

            if (!string.IsNullOrWhiteSpace(uuid))
            {
                filters.Add(new FilterModel {
                    PropertyName = "UUID", Operation = Operation.StartsWith, Value = uuid
                });
            }
            if (terminalType != TerminalType.None)
            {
                filters.Add(new FilterModel {
                    PropertyName = "TerminalType", Operation = Operation.Equals, Value = terminalType.ToString()
                });
            }

            var paginatedList = paymentService.GetPaginatedList(filters, FilterJoin.And, true, "ModifiedTimestamp", page, rows);
            var totalPages    = Math.Ceiling((float)paginatedList.TotalCount / (float)rows);
            var jsonData      = new
            {
                total = totalPages,
                page,
                records = paginatedList.TotalCount,
                rows    = paginatedList.Models
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
    // read only => no ref
    public TerminalState GetTerminalState(TerminalType type)
    {
        Terminals terminal = GetTerminalByType(type);

        return(terminal.m_state);
    }
示例#33
0
        /// <summary>
        /// 词法分析程序主体
        /// </summary>
        /// <param name="inputStr">要分析的文本</param>
        /// <returns>词法分析结果</returns>
        public static TokenResult Analyse(string inputStr)
        {
            if (inputStr == null || inputStr == "")
            {
                return(new TokenResult());
            }
            input  = inputStr;
            index  = 0;
            line   = 1;
            buffer = "";
            ch     = input[index];

            isAnalysing = true;
            result      = new TokenResult();

            while (isAnalysing)
            {
                Concat();
                try
                {
                    if (Array.IndexOf(symbols, buffer) != -1)
                    {
                        AnalyseSymbol();
                    }
                    else if (Char.IsDigit(ch))
                    {
                        AnalyseNumber();
                    }
                    else if (Char.IsLetter(ch) || ch == '_')
                    {
                        AnalyseIdAndKey();
                    }
                    else if (Char.IsWhiteSpace(ch))
                    {
                        AnalyseRow();
                    }
                    else
                    {
                        throw new Exception("符号错误:未知符号");
                    }
                }
                catch (Exception ex)
                {
                    error = new ErrorInfo(line, ex.Message);
                    result.ErrorInfos.Add(error);
                }
                finally
                {
                    Peek();
                }
            }

            // 添加结束符
            buffer = "$";
            value  = TerminalType.END;
            Read();

            result.IsSuccess = result.ErrorInfos.Count == 0;

            return(result);
        }
 public _Token(TerminalType type, string value)
 {
     Type  = type;
     Value = value;
     PrecedingWhiteSpace = "";
 }
示例#35
0
 /// <summary>
 /// write only
 /// </summary>
 public static void Add(object message, TerminalType type)
 {
     Add(new TerminalItem(type, message.ToString()));
 }
 public _Token(TerminalType type, string value, string precedingWhiteSpace) : this(type, value)
 {
     PrecedingWhiteSpace = precedingWhiteSpace;
 }
示例#37
0
 internal TerminalParam()
 {
     _encoding = EncodingType.EUC_JP;
     _logtype = LogType.None;
     _terminalType = TerminalType.XTerm;
     _localecho = false;
     _lineFeedRule = LineFeedRule.Normal;
     _transmitnl = NewLine.CR;
     _renderProfile = null;
 }
 protected _TerminalExpression(TerminalType type, T value)
 {
     Type  = type;
     Value = value;
 }
示例#39
0
 public virtual void Import(ConfigNode data)
 {
     _encoding = ParseEncoding(data["encoding"]);
     _terminalType = (TerminalType)EnumDescAttribute.For(typeof(TerminalType)).FromName(data["terminal-type"], TerminalType.VT100);
     _transmitnl = (NewLine)EnumDescAttribute.For(typeof(NewLine)).FromName(data["transmit-nl"], NewLine.CR);
     _localecho = GUtil.ParseBool(data["localecho"], false);
     //_lineFeedByCR = GUtil.ParseBool((string)data["linefeed-by-cr"], false);
     _lineFeedRule = (LineFeedRule)EnumDescAttribute.For(typeof(LineFeedRule)).FromName(data["linefeed"], LineFeedRule.Normal);
     _caption = data["caption"];
     if(data.Contains("font-name")) //���ڂ��Ȃ���΋�̂܂�
         _renderProfile = new RenderProfile(data);
 }
示例#40
0
        /// <summary>
        /// Initiates the SSH connection process by getting the <see cref="IProtocolService"/> instance and calling
        /// <see cref="IProtocolService.AsyncSSHConnect"/>.  This is an asynchronous process:  the <see cref="SuccessfullyExit"/> method is called when the
        /// connection is established successfully and <see cref="ConnectionFailed"/> method is called when we are unable to establish the connection.
        /// </summary>
        public void AsyncConnect()
        {
            ITerminalEmulatorService terminalEmulatorService =
                (ITerminalEmulatorService)_poderosaWorld.PluginManager.FindPlugin("org.poderosa.terminalemulator", typeof(ITerminalEmulatorService));
            IProtocolService protocolService = (IProtocolService)_poderosaWorld.PluginManager.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));

            // Create and initialize the SSH login parameters
            ISSHLoginParameter sshLoginParameter = protocolService.CreateDefaultSSHParameter();

            sshLoginParameter.Account = Username;

            if (!String.IsNullOrEmpty(IdentityFile))
            {
                sshLoginParameter.AuthenticationType = AuthenticationType.PublicKey;
                sshLoginParameter.IdentityFileName   = IdentityFile;
            }

            else
            {
                sshLoginParameter.AuthenticationType = AuthenticationType.Password;

                if (Password != null && Password.Length > 0)
                {
                    IntPtr passwordBytes = Marshal.SecureStringToGlobalAllocAnsi(Password);
                    sshLoginParameter.PasswordOrPassphrase = Marshal.PtrToStringAnsi(passwordBytes);
                }
            }

            sshLoginParameter.Method = (SSHProtocol)Enum.Parse(typeof(SSHProtocol), SshProtocol.ToString("G"));

            // Create and initialize the various socket connection properties
            ITCPParameter tcpParameter = (ITCPParameter)sshLoginParameter.GetAdapter(typeof(ITCPParameter));

            tcpParameter.Destination = HostName;
            tcpParameter.Port        = Port;

            // Set the UI settings to use for the terminal itself
            terminalEmulatorService.TerminalEmulatorOptions.RightButtonAction = MouseButtonAction.Paste;
            _settings = terminalEmulatorService.CreateDefaultTerminalSettings(tcpParameter.Destination, null);

            _settings.BeginUpdate();
            _settings.TerminalType            = (ConnectionParam.TerminalType)Enum.Parse(typeof(ConnectionParam.TerminalType), TerminalType.ToString("G"));
            _settings.RenderProfile           = terminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
            _settings.RenderProfile.BackColor = BackColor;
            _settings.RenderProfile.ForeColor = ForeColor;
            _settings.RenderProfile.FontName  = Font.Name;
            _settings.RenderProfile.FontSize  = Font.Size;
            _settings.EndUpdate();

            ITerminalParameter param = (ITerminalParameter)tcpParameter.GetAdapter(typeof(ITerminalParameter));

            param.SetTerminalName(_settings.TerminalType.ToString("G").ToLower());

            // Initiate the connection process
            protocolService.AsyncSSHConnect(this, sshLoginParameter);
        }