TerminalParam.cs
上传用户:szltgg
上传日期:2019-05-16
资源大小:604k
文件大小:43k
- /*
- * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
- * $Id: TerminalParam.cs,v 1.2 2005/04/20 08:45:48 okajima Exp $
- */
- using System;
- using System.Diagnostics;
- using System.Collections;
- using System.IO;
- using System.Text;
- using System.Windows.Forms;
- using System.Net;
- using System.Net.Sockets;
- using Poderosa.Terminal;
- #if !MACRODOC
- using Poderosa.Config;
- using Poderosa.Communication;
- using Poderosa.Text;
- using Poderosa.LocalShell;
- #endif
- using Poderosa.Toolkit;
- namespace Poderosa.ConnectionParam {
- /*
- * TerminalParam偼儅僋儘偐傜傕僼儖偵傾僋僙僗壜擻偵偡傞偨傔public偵偡傞
- * 岞奐偡傞昁梫偺側偄儊僜僢僪傪internal偵偡傞
- */
- //Granados撪偺AuthenticationType偲摨堦偩偑丄婲摦偺崅懍壔偺偨傔巊傢側偄
-
- /// <summary>
- /// <ja>SSH偱偺擣徹曽朄傪帵偟傑偡丅</ja>
- /// <en>Specifies the authemtication method of SSH.</en>
- /// </summary>
- [EnumDesc(typeof(AuthType))]
- public enum AuthType {
- /// <summary>
- /// <ja>僷僗儚乕僪擣徹</ja>
- /// <en>Authentication using password.</en>
- /// </summary>
- [EnumValue(Description="Enum.AuthType.Password")]
- Password,
- /// <summary>
- /// <ja>庤尦偺旈枾尞偲儕儌乕僩儂僗僩偵搊榐偟偨岞奐尞傪巊偭偨擣徹</ja>
- /// <en>Authentication using the local private key and the remote public key.</en>
- /// </summary>
- [EnumValue(Description="Enum.AuthType.PublicKey")]
- PublicKey,
- /// <summary>
- /// <ja>僐儞僜乕儖忋偱僷僗儚乕僪傪擖椡偡傞擣徹</ja>
- /// <en>Authentication by sending the password through the console.</en>
- /// </summary>
- [EnumValue(Description="Enum.AuthType.KeyboardInteractive")]
- KeyboardInteractive
- }
- /// <summary>
- /// <ja>僄儞僐乕僨傿儞僌傪帵偟傑偡丅</ja>
- /// <en>Specifies the encoding of the connection.</en>
- /// <seealso cref="TerminalParam.Encoding"/>
- /// </summary>
- [EnumDesc(typeof(EncodingType))]
- public enum EncodingType {
- /// <summary>
- /// <ja>iso-8859-1</ja>
- /// <en>iso-8859-1</en>
- /// </summary>
- [EnumValue(Description="Enum.EncodingType.ISO8859_1")] ISO8859_1,
- /// <summary>
- /// <ja>utf-8</ja>
- /// <en>utf-8</en>
- /// </summary>
- [EnumValue(Description="Enum.EncodingType.UTF8")] UTF8,
- /// <summary>
- /// <ja>euc-jp</ja>
- /// <en>euc-jp (This encoding is primarily used with Japanese characters.)</en>
- /// </summary>
- [EnumValue(Description="Enum.EncodingType.EUC_JP")] EUC_JP,
- /// <summary>
- /// <ja>shift-jis</ja>
- /// <en>shift-jis (This encoding is primarily used with Japanese characters.)</en>
- /// </summary>
- [EnumValue(Description="Enum.EncodingType.SHIFT_JIS")] SHIFT_JIS
- }
- /// <summary>
- /// <ja>儘僌偺庬椶傪帵偟傑偡丅</ja>
- /// <en>Specifies the log type.</en>
- /// </summary>
- [EnumDesc(typeof(LogType))]
- public enum LogType {
- /// <summary>
- /// <ja>儘僌偼偲傝傑偣傫丅</ja>
- /// <en>The log is not recorded.</en>
- /// </summary>
- [EnumValue(Description="Enum.LogType.None")] None,
- /// <summary>
- /// <ja>僥僉僗僩儌乕僪偺儘僌偱偡丅偙傟偑昗弨偱偡丅</ja>
- /// <en>The log is a plain text file. This is standard.</en>
- /// </summary>
- [EnumValue(Description="Enum.LogType.Default")] Default,
- /// <summary>
- /// <ja>僶僀僫儕儌乕僪偺儘僌偱偡丅</ja>
- /// <en>The log is a binary file.</en>
- /// </summary>
- [EnumValue(Description="Enum.LogType.Binary")] Binary,
- /// <summary>
- /// <ja>XML偱曐懚偟傑偡丅傑偨撪晹揑側僶僌捛愓偵偍偄偰偙偺儌乕僪偱偺儘僌嵦庢傪偍婅偄偡傞偙偲偑偁傝傑偡丅</ja>
- /// <en>The log is an XML file. We may ask you to record the log in this type for debugging.</en>
- /// </summary>
- [EnumValue(Description="Enum.LogType.Xml")] Xml
- }
- /// <summary>
- /// <ja>憲怣帪偺夵峴偺庬椶傪帵偟傑偡丅</ja>
- /// <en>Specifies the new-line characters for transmission.</en>
- /// </summary>
- [EnumDesc(typeof(NewLine))]
- public enum NewLine {
- /// <summary>
- /// CR
- /// </summary>
- [EnumValue(Description="Enum.NewLine.CR")] CR,
- /// <summary>
- /// LF
- /// </summary>
- [EnumValue(Description="Enum.NewLine.LF")] LF,
- /// <summary>
- /// CR+LF
- /// </summary>
- [EnumValue(Description="Enum.NewLine.CRLF")] CRLF
- }
- /// <summary>
- /// <ja>僞乕儈僫儖偺庬暿傪帵偟傑偡丅</ja>
- /// <en>Specifies the type of the terminal.</en>
- /// </summary>
- /// <remarks>
- /// <ja>XTerm偵偼VT100偵偼側偄偄偔偮偐偺僄僗働乕僾僔乕働儞僗偑娷傑傟偰偄傑偡丅</ja>
- /// <en>XTerm supports several escape sequences in addition to VT100.</en>
- /// <ja>KTerm偼拞恎偼XTerm偲堦弿偱偡偑丄SSH傗Telnet偺愙懕僆僾僔儑儞偵偍偄偰僞乕儈僫儖偺庬椶傪帵偡暥帤楍偲偟偰"kterm"偑僙僢僩偝傟傑偡丅</ja>
- /// <en>Though the functionality of KTerm is identical to XTerm, the string "kterm" is used for specifying the type of the terminal in the connection of Telnet or SSH.</en>
- /// <ja>偙偺愝掕偼丄懡偔偺応崌TERM娐嫬曄悢偺抣偵塭嬁偟傑偡丅</ja>
- /// <en>In most cases, this setting affects the TERM environment variable.</en>
- /// </remarks>
- [EnumDesc(typeof(TerminalType))]
- public enum TerminalType {
- /// <summary>
- /// vt100
- /// </summary>
- [EnumValue(Description="Enum.TerminalType.VT100")] VT100,
- /// <summary>
- /// xterm
- /// </summary>
- [EnumValue(Description="Enum.TerminalType.XTerm")] XTerm,
- /// <summary>
- /// kterm
- /// </summary>
- [EnumValue(Description="Enum.TerminalType.KTerm")] KTerm
- }
- /// <summary>
- /// <ja>愙懕偺庬椶傪帵偟傑偡丅</ja>
- /// <en>Specifies the type of the connection.</en>
- /// </summary>
- public enum ConnectionMethod {
- /// <summary>
- /// Telnet
- /// </summary>
- Telnet,
- /// <summary>
- /// SSH1
- /// </summary>
- SSH1,
- /// <summary>
- /// SSH2
- /// </summary>
- SSH2
- }
- /// <summary>
- /// <ja>攚宨夋憸偺埵抲傪巜掕偟傑偡丅</ja>
- /// <en>Specifies the position of the background image.</en>
- /// </summary>
- [EnumDesc(typeof(ImageStyle))]
- public enum ImageStyle {
- /// <summary>
- /// <ja>拞墰</ja>
- /// <en>Center</en>
- /// </summary>
- [EnumValue(Description="Enum.ImageStyle.Center")] Center,
- /// <summary>
- /// <ja>嵍忋</ja>
- /// <en>Upper left corner</en>
- /// </summary>
- [EnumValue(Description="Enum.ImageStyle.TopLeft")] TopLeft,
- /// <summary>
- /// <ja>塃忋</ja>
- /// <en>Upper right corner</en>
- /// </summary>
- [EnumValue(Description="Enum.ImageStyle.TopRight")] TopRight,
- /// <summary>
- /// <ja>嵍壓</ja>
- /// <en>Lower left corner</en>
- /// </summary>
- [EnumValue(Description="Enum.ImageStyle.BottomLeft")] BottomLeft,
- /// <summary>
- /// <ja>塃壓</ja>
- /// <en>Lower right corner</en>
- /// </summary>
- [EnumValue(Description="Enum.ImageStyle.BottomRight")] BottomRight,
- /// <summary>
- /// <ja>怢弅偟偰慡懱偵昞帵</ja>
- /// <en>The image covers the whole area of the console by expansion</en>
- /// </summary>
- [EnumValue(Description="Enum.ImageStyle.Scaled")] Scaled
- }
- /// <summary>
- /// <ja>庴怣偟偨暥帤偵懳偡傞夵峴曽朄傪帵偟傑偡丅</ja>
- /// <en>Specifies line breaking style.</en>
- /// </summary>
- [EnumDesc(typeof(LineFeedRule))]
- public enum LineFeedRule {
- /// <summary>
- /// <ja>昗弨</ja>
- /// <en>Standard</en>
- /// </summary>
- [EnumValue(Description="Enum.LineFeedRule.Normal")] Normal,
- /// <summary>
- /// <ja>LF偱夵峴偟CR傪柍帇</ja>
- /// <en>LF:Line Break, CR:Ignore</en>
- /// </summary>
- [EnumValue(Description="Enum.LineFeedRule.LFOnly")] LFOnly,
- /// <summary>
- /// <ja>CR偱夵峴偟LF傪柍帇</ja>
- /// <en>CR:Line Break, LF:Ignore</en>
- /// </summary>
- [EnumValue(Description="Enum.LineFeedRule.CROnly")] CROnly
- }
- /// <summary>
- /// <ja>愙懕傪奐偔偲偒偺僷儔儊乕僞偺婎掙僋儔僗偱偡丅</ja>
- /// <en>Implements the basic functionality common to connections.</en>
- /// <seealso cref="TCPTerminalParam"/>
- /// <seealso cref="TelnetTerminalParam"/>
- /// <seealso cref="SSHTerminalParam"/>
- /// <seealso cref="SerialTerminalParam"/>
- /// <seealso cref="CygwinTerminalParam"/>
- /// </summary>
- [Serializable()]
- public abstract class TerminalParam : ICloneable {
- internal EncodingType _encoding;
- internal TerminalType _terminalType;
- internal LogType _logtype;
- internal string _logpath;
- internal bool _logappend;
- internal bool _localecho;
- internal LineFeedRule _lineFeedRule;
- internal NewLine _transmitnl;
- internal string _caption;
- internal RenderProfile _renderProfile;
-
- internal TerminalParam() {
- _encoding = EncodingType.EUC_JP;
- _logtype = LogType.None;
- _terminalType = TerminalType.XTerm;
- _localecho = false;
- _lineFeedRule = LineFeedRule.Normal;
- _transmitnl = NewLine.CR;
- _renderProfile = null;
- }
- internal TerminalParam(TerminalParam r) {
- Import(r);
- }
- 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;
- }
- ///
- ///
- ///
- ///
- public override bool Equals(object t_) {
- TerminalParam t = t_ as TerminalParam;
- if(t==null) return false;
- return
- _encoding==t.Encoding &&
- _localecho==t.LocalEcho &&
- _transmitnl==t.TransmitNL &&
- _lineFeedRule==t.LineFeedRule &&
- _terminalType==t.TerminalType;
- }
- ///
- ///
- ///
- public override int GetHashCode() {
- return _encoding.GetHashCode() + _localecho.GetHashCode()*2 + _transmitnl.GetHashCode()*3 + _lineFeedRule.GetHashCode()*4 + _terminalType.GetHashCode()*5;
- }
- ///
- ///
- ///
- public abstract object Clone();
- #if !MACRODOC
- public abstract string Description { get; }
- public abstract string ShortDescription { get; }
- public abstract string MethodName { get; }
- public virtual void Export(ConfigNode node) {
- node["encoding"] = EnumDescAttribute.For(typeof(EncodingType)).GetDescription(_encoding);
- node["terminal-type"] = EnumDescAttribute.For(typeof(TerminalType)).GetName(_terminalType);
- node["transmit-nl"] = EnumDescAttribute.For(typeof(NewLine)).GetName(_transmitnl);
- node["localecho"] = _localecho.ToString();
- node["linefeed"] = EnumDescAttribute.For(typeof(LineFeedRule)).GetName(_lineFeedRule);
- if(_caption!=null && _caption.Length>0) node["caption"] = _caption;
- if(_renderProfile!=null) _renderProfile.Export(node);
- }
- 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);
- }
-
- public EncodingProfile EncodingProfile {
- get {
- return EncodingProfile.Get(_encoding);
- }
- set {
- _encoding = value.Type;
- }
- }
- #endif
- /// <summary>
- /// <ja>偙偺TerminalParam偱愙懕傪奐偄偨偲偒偺怓丒僼僅儞僩側偳偺愝掕傪廂榐偟偨僆僽僕僃僋僩偱偡丅</ja>
- /// <en>Gets or sets the appearances of the console such as colors or fonts.</en>
- /// </summary>
- /// <remarks>
- /// <ja>摿偵壗傕巜掕偟側偐偄偐null傪僙僢僩偡傞偲丄僆僾僔儑儞僟僀傾儘僌偱愝掕偟偨撪梕偑巊梡偝傟傑偡丅</ja>
- /// <en>If you do not set anything or set null, the appearance is same as the setting of the option dialo.</en>
- /// </remarks>
- /// <seealso cref="RenderProfile"/>
- public RenderProfile RenderProfile {
- get {
- return _renderProfile;
- }
- set {
- _renderProfile = value;
- }
- }
-
- /// <summary>
- /// <ja>偙偺愙懕偺僄儞僐乕僨傿儞僌偱偡丅</ja>
- /// <en>Gets or sets the encoding of the connection.</en>
- /// </summary>
- public EncodingType Encoding {
- get {
- return _encoding;
- }
- set {
- _encoding = value;
- }
- }
- /// <summary>
- /// <ja>僞乕儈僫儖偺庬暿偱偡丅</ja>
- /// <en>Gets or sets the type of the terminal.</en>
- /// </summary>
- public TerminalType TerminalType {
- get {
- return _terminalType;
- }
- set {
- _terminalType = value;
- }
- }
- /// <summary>
- /// <ja>儘僌偺庬暿偱偡丅</ja>
- /// <en>Gets or sets the type of the log.</en>
- /// </summary>
- public LogType LogType {
- get {
- return _logtype;
- }
- set {
- _logtype = value;
- }
- }
- /// <summary>
- /// <ja>儘僌僼傽僀儖偺僼儖僷僗偱偡丅</ja>
- /// <en>Gets or sets the full path of the log file.</en>
- /// </summary>
- public string LogPath {
- get {
- return _logpath;
- }
- set {
- _logpath = value;
- }
- }
- /// <summary>
- /// <ja>儘僌偺庬暿偲僼傽僀儖柤傪僆僾僔儑儞僟僀傾儘僌偱巜掕偟偨撪梕偵婎偯偒帺摦揑偵愝掕偟傑偡丅</ja>
- /// <en>Sets the type and the file name of the log based on the settings in the option dialog.</en>
- /// </summary>
- public void AutoFillLogPath() {
- #if !MACRODOC
- _logtype = GEnv.Options.DefaultLogType;
- if(_logtype!=LogType.None)
- _logpath = GUtil.CreateLogFileName(this.ShortDescription);
- else
- _logpath = "";
- #endif
- }
- /// <summary>
- /// <ja>摨柤僼傽僀儖偑偁傞応崌丄儘僌僼傽僀儖偵捛婰偡傞偐忋彂偒偡傞偐傪巜掕偟傑偡丅</ja>
- /// <en>Specifies whether the connection appends or overwrites the log file in case that the file exists already.</en>
- /// </summary>
- public bool LogAppend {
- get {
- return _logappend;
- }
- set {
- _logappend = false;
- }
- }
- /// <summary>
- /// <ja>憲怣帪偺夵峴愝掕偱偡丅</ja>
- /// <en>Gets or sets the new-line characters for transmission.</en>
- /// </summary>
- public NewLine TransmitNL {
- get {
- return _transmitnl;
- }
- set {
- _transmitnl = value;
- }
- }
- /// <summary>
- /// <ja>儘乕僇儖僄僐乕傪偡傞偐偳偆偐偱偡丅</ja>
- /// <en>Specifies whether the local echo is performed.</en>
- /// </summary>
- public bool LocalEcho {
- get {
- return _localecho;
- }
- set {
- _localecho = value;
- }
- }
- /// <summary>
- /// <ja>庴怣偟偨暥帤偵懳偟偰夵峴偡傞偐偳偆偐偱偡丅</ja>
- /// <en>Specifies line breaking style corresponding to received characters.</en>
- /// </summary>
- public LineFeedRule LineFeedRule {
- get {
- return _lineFeedRule;
- }
- set {
- _lineFeedRule = value;
- }
- }
- /// <summary>
- /// <ja>僞僽側偳偵昞帵偡傞偨傔偺尒弌偟偱偡丅</ja>
- /// <en>Gets or sets the caption of the tab.</en>
- /// <ja>摿偵僙僢僩偟側偄応崌丄愙懕愭偺儂僗僩柤傪棙梡偟偰帺摦揑偵偮偗傜傟傑偡丅</ja>
- /// <en>If you do not specify anything, the caption is set automatically using the host name.</en>
- /// </summary>
- public string Caption {
- get {
- return _caption;
- }
- set {
- _caption = value;
- }
- }
- #if !MACRODOC
- public void FeedLogOption() {
- if(GEnv.Options.DefaultLogType!=LogType.None) {
- _logtype = GEnv.Options.DefaultLogType;
- _logpath = GUtil.CreateLogFileName(this.ShortDescription);
- }
- }
- public static TerminalParam CreateFromConfigNode(ConfigNode sec) {
- string type = sec["type"];
- TerminalParam param;
- if(type=="serial")
- param = new SerialTerminalParam();
- else if(type=="tcp") {
- ConnectionMethod cm = ParseMethod(sec["method"]);
- if(cm==ConnectionMethod.Telnet)
- param = new TelnetTerminalParam();
- else
- param = new SSHTerminalParam();
- }
- else if(type=="cygwin")
- param = new CygwinTerminalParam();
- else if(type=="sfu")
- param = new SFUTerminalParam();
- else
- throw new Exception("invalid format");
- param.Import(sec);
- return param;
- }
- private static EncodingType ParseEncoding(string val) {
- return (EncodingType)EnumDescAttribute.For(typeof(EncodingType)).FromDescription(val, EncodingType.UTF8);
- }
- protected static ConnectionMethod ParseMethod(string val) {
- if(val=="SSH1")
- return ConnectionMethod.SSH1;
- if(val=="SSH2")
- return ConnectionMethod.SSH2;
- if(val=="Telnet")
- return ConnectionMethod.Telnet;
- throw new FormatException(String.Format("{0} is unkown method", val));
- }
- #endif
- }
- /// <summary>
- /// <ja>TCP偵婎偯偄偨愙懕偺僷儔儊乕僞傪昞尰偟傑偡丅</ja>
- /// <en>Implements the parameters of the connection using TCP. (i.e. Telnet and SSH)</en>
- /// <seealso cref="TelnetTerminalParam"/>
- /// <seealso cref="SSHTerminalParam"/>
- /// </summary>
- [Serializable()]
- public abstract class TCPTerminalParam : TerminalParam {
- internal string _host;
- internal int _port;
- internal ConnectionMethod _method;
- internal TCPTerminalParam() {
- _method = ConnectionMethod.Telnet;
- }
- internal TCPTerminalParam(TCPTerminalParam r) : base(r) {
- _host = r._host;
- _port = r._port;
- _method = r._method;
- }
- internal void Import(TCPTerminalParam r) {
- base.Import(r);
- _host = r._host;
- _port = r._port;
- _method = r._method;
- }
- ///
- ///
- ///
- public override bool Equals(object t_) {
- TCPTerminalParam t = t_ as TCPTerminalParam;
- if(t==null) return false;
- return base.Equals(t) && _host==t.Host && _port==t.Port && _method==t.Method;
- }
- ///
- ///
- ///
- public override int GetHashCode() {
- return base.GetHashCode() + _host.GetHashCode() + _port.GetHashCode()*2 + _method.GetHashCode()*3;
- }
- /// <summary>
- /// <ja>愙懕愭偺儂僗僩柤偱偡丅</ja>
- /// <en>Gets or sets the host name.</en>
- /// </summary>
- /// <remarks>
- /// <ja>傑偨偼"192.168.10.1"側偳偺IP傾僪儗僗偺暥帤楍昞尰傕壜擻偱偡丅</ja>
- /// <en>The IP address format such as "192.168.10.1" is also allowed.</en>
- /// </remarks>
- public virtual string Host {
- get {
- return _host;
- }
- set {
- _host = value;
- }
- }
- /// <summary>
- /// <ja>愙懕愭偺億乕僩斣崋偱偡丅</ja>
- /// <en>Gets or sets the port number.</en>
- /// </summary>
- public virtual int Port {
- get {
- return _port;
- }
- set {
- _port = value;
- }
- }
- /// <summary>
- /// <ja>愙懕偺庬暿偱偡丅</ja>
- /// <en>Gets or sets the connection method.</en>
- /// </summary>
- public virtual ConnectionMethod Method {
- get {
- return _method;
- }
- set {
- #if !MACRODOC
- throw new ArgumentException(GEnv.Strings.GetString("Message.TCPTerminalParam.PropCannotBeSet"));
- #endif
- }
- }
- /// <summary>
- /// <ja>偙偺愙懕偑SSH偱偁傟偽true偱偡丅</ja>
- /// <en>Returns true if the connection method is SSH.</en>
- /// </summary>
- public bool IsSSH {
- get {
- return _method==ConnectionMethod.SSH1 || _method==ConnectionMethod.SSH2;
- }
- }
- #if !MACRODOC
- public override void Export(ConfigNode node) {
- node["type"] = "tcp";
- node["host"] = _host;
- node["port"] = _port.ToString();
- node["method"] = _method.ToString();
- base.Export(node);
- }
- public override void Import(ConfigNode data) {
- _host = data["host"];
- _port = ParsePort(data["port"]);
- _method = ParseMethod(data["method"]);
- base.Import(data);
- }
- //TerminalUtil傊堏摦偡傋偒偐傕
- private static int ParsePort(string val) {
- try {
- return Int32.Parse(val);
- }
- catch(FormatException e) {
- throw e;
- }
- }
- public static TCPTerminalParam Fake {
- get {
- TelnetTerminalParam p = new TelnetTerminalParam();
- p.EncodingProfile = EncodingProfile.Get(EncodingType.EUC_JP);
- return p;
- }
- }
- public override string ShortDescription {
- get {
- return _host;
- }
- }
- public override string MethodName {
- get {
- return _method==ConnectionMethod.SSH1? "SSH1" : _method==ConnectionMethod.SSH2? "SSH2" : "telnet";
- }
- }
- #endif
- }
- /// <summary>
- /// <ja>Telnet偵傛傞愙懕僷儔儊乕僞傪帵偡僋儔僗</ja>
- /// <en>Implements the parameters of the Telnet connections.</en>
- /// </summary>
- [Serializable()]
- public class TelnetTerminalParam : TCPTerminalParam {
- /// <summary>
- /// <ja>儂僗僩柤傪巜掕偟偰嶌惉偟傑偡丅</ja>
- /// <en>Initializes with the host name.</en>
- /// <seealso cref="Poderosa.Macro.ConnectionList.Open"/>
- /// </summary>
- /// <remarks>
- /// <ja>億乕僩偼23偵愝掕偝傟傑偡丅</ja>
- /// <en>The port number is set to 23.</en>
- /// <ja>懠偺僷儔儊乕僞偼師偺傛偆偵弶婜壔偝傟傑偡丅</ja>
- /// <en>Other parameters are initialized as following:</en>
- /// <list type="table">
- /// <item><term><ja>僄儞僐乕僨傿儞僌</ja><en>Encoding</en></term><description><ja>EUC-JP</ja><en>iso-8859-1</en></description></item>丂
- /// <item><term><ja>僞乕儈僫儖僞僀僾</ja><en>Terminal Type</en></term><description>xterm</description></item>
- /// <item><term><ja>儘僌</ja><en>Log</en></term><description><ja>庢摼偟側偄</ja><en>None</en></description></item>丂丂丂丂丂丂丂
- /// <item><term><ja>儘乕僇儖僄僐乕</ja><en>Local echo</en></term><description><ja>偟側偄</ja><en>Don't</en></description></item>丂丂
- /// <item><term><ja>憲怣帪夵峴</ja><en>New line</en></term><description>CR</description></item>丂丂丂丂
- /// </list>
- /// <ja>愙懕傪奐偔偵偼丄<see cref="Poderosa.Macro.ConnectionList.Open"/>儊僜僢僪偺堷悢偲偟偰TelnetTerminalParam僆僽僕僃僋僩傪搉偟傑偡丅</ja>
- /// <en>To open a new connection, pass the TelnetTerminalParam object to the <see cref="Poderosa.Macro.ConnectionList.Open"/> method.</en>
- /// </remarks>
- /// <param name="host"><ja>儂僗僩柤</ja><en>The host name.</en></param>
- public TelnetTerminalParam(string host) {
- _method = ConnectionMethod.Telnet;
- _host = host;
- _port = 23;
- }
- internal TelnetTerminalParam() {
- _method = ConnectionMethod.Telnet;
- }
- internal TelnetTerminalParam(TelnetTerminalParam r) : base(r) {
- }
- ///
- ///
- ///
- public override object Clone() {
- return new TelnetTerminalParam(this);
- }
- #if !MACRODOC
- public override void Import(ConfigNode data) {
- base.Import(data);
- }
- public override string Description {
- get {
- return _host;
- }
- }
- #endif
- }
- /// <summary>
- /// <ja>SSH偵傛傞愙懕僷儔儊乕僞偱偡丅</ja>
- /// <en>Implements the parameters of SSH connections.</en>
- /// </summary>
- [Serializable()]
- public class SSHTerminalParam : TCPTerminalParam {
- internal string _account;
- internal string _passphrase; //偙傟偼僔儕傾儔僀僘偺懳徾奜丅儊儌儕忋偵帩偮偐偳偆偐傕僆僾僔儑儞
- internal AuthType _auth;
- internal string _identityfile;
- /// <summary>
- /// <ja>儂僗僩柤丄傾僇僂儞僩丄僷僗儚乕僪傪巜掕偟偰嶌惉偟傑偡丅</ja>
- /// <en>Initializes with the host name, the account, and the password.</en>
- /// <seealso cref="Poderosa.Macro.ConnectionList.Open"/>
- /// </summary>
- /// <remarks>
- /// <ja>億乕僩偼22偵愝掕偝傟傑偡丅</ja>
- /// <en>The port number is set to 22.</en>
- /// <ja>懠偺僷儔儊乕僞偼師偺傛偆偵弶婜壔偝傟傑偡丅</ja>
- /// <en>Other parameters are initialized as following:</en>
- /// <list type="table">
- /// <item><term><ja>僄儞僐乕僨傿儞僌</ja><en>Encoding</en></term><description><ja>EUC-JP</ja><en>iso-8859-1</en></description></item>丂
- /// <item><term><ja>僞乕儈僫儖僞僀僾</ja><en>Terminal Type</en></term><description>xterm</description></item>
- /// <item><term><ja>儘僌</ja><en>Log</en></term><description><ja>庢摼偟側偄</ja><en>None</en></description></item>丂丂丂丂丂丂丂
- /// <item><term><ja>儘乕僇儖僄僐乕</ja><en>Local echo</en></term><description><ja>偟側偄</ja><en>Don't</en></description></item>丂丂
- /// <item><term><ja>憲怣帪夵峴</ja><en>New line</en></term><description>CR</description></item>丂丂丂丂
- /// <item><term><ja>擣徹曽朄</ja><en>Authentication Method</en></term><description><ja>僷僗儚乕僪</ja><en>Password</en></description></item>丂丂丂丂
- /// </list>
- /// <ja>愙懕傪奐偔偵偼丄ConnectionList僆僽僕僃僋僩偺<see cref="Poderosa.Macro.ConnectionList.Open"/>儊僜僢僪偺堷悢偲偟偰SSHTerminalParam僆僽僕僃僋僩傪搉偟傑偡丅</ja>
- /// <en>To open a new connection, pass the SSHTerminalParam object to the <see cref="Poderosa.Macro.ConnectionList.Open"/> method of the ConnectionList object.</en>
- /// </remarks>
- /// <param name="method"><ja>SSH1傑偨偼SSH2</ja><en>SSH1 or SSH2.</en></param>
- /// <param name="host"><ja>儂僗僩柤</ja><en>The host name.</en></param>
- /// <param name="account"><ja>傾僇僂儞僩柤</ja><en>The account</en></param>
- /// <param name="password"><ja>僷僗儚乕僪傑偨偼旈枾尞偺僷僗僼儗乕僘</ja><en>The password or the passphrase of the private key.</en></param>
- public SSHTerminalParam(ConnectionMethod method, string host, string account, string password) {
- if(method==ConnectionMethod.Telnet) throw new ArgumentException("Telnet is specified in the constructor of SSHTerminalParam");
- _method = method;
- _host = host;
- _port = 22;
- _account = account;
- _passphrase = password;
- _auth = AuthType.Password;
- }
- internal SSHTerminalParam(SSHTerminalParam r) : base(r) {
- _account = r._account;
- _auth = r._auth;
- _identityfile = r._identityfile;
- _passphrase = r._passphrase;
- }
- internal SSHTerminalParam() {
- _method = ConnectionMethod.SSH2;
- _auth = AuthType.Password;
- _port = 22;
- }
- ///
- ///
- ///
- public override object Clone() {
- return new SSHTerminalParam(this);
- }
- ///
- ///
- ///
- public override bool Equals(object t_) {
- SSHTerminalParam t = t_ as SSHTerminalParam;
- if(t==null) return false;
- return base.Equals(t) && _account==t.Account && _auth==t.AuthType;
- }
- ///
- ///
- ///
- public override int GetHashCode() {
- return base.GetHashCode() + _account.GetHashCode() + _auth.GetHashCode()*2;
- }
- /// <summary>
- /// <ja>傾僇僂儞僩柤偱偡丅</ja>
- /// <en>Gets or sets the account.</en>
- /// </summary>
- public string Account {
- get {
- return _account;
- }
- set {
- _account = value;
- }
- }
- /// <summary>
- /// <ja>愙懕偺庬暿偱偡丅</ja>
- /// <en>Gets or sets the connection method.</en>
- /// </summary>
- public override ConnectionMethod Method {
- set {
- #if !MACRODOC
- if(value==ConnectionMethod.Telnet)
- throw new ArgumentException(GEnv.Strings.GetString("Mesage.SSHTerminalParam.MethodSetError"));
- _method = value;
- #endif
- }
- }
- /// <summary>
- /// <ja>儐乕僓擣徹偺曽朄偱偡丅</ja>
- /// <en>Gets or sets the authentication method.</en>
- /// </summary>
- /// <remarks>
- /// <para><ja>偙傟傪PublicKey偵偟偨応崌丄IdentityFile僾儘僷僥傿偼旈枾尞僼傽僀儖傪巜偟偰偄側偄偲偄偗傑偣傫丅</ja>
- /// <en>If the PublicKey is specified, the IdentityFile property must indicate a correct private key file.</en></para>
- /// <para><ja>Password偵偟偨応崌丄Passphrase僾儘僷僥傿偺抣偑僷僗儚乕僪偲偟偰巊傢傟傑偡丅</ja>
- /// <en>If the Password is specified, the value of the Passphrase property is used as the login password.</en></para>
- /// <para><ja>儅僋儘偐傜偼丄KeyboardInteractive傪僙僢僩偟側偄偱偔偩偝偄丅</ja>
- /// <en>The macro cannot use KeyboardInteractive method.</en></para>
- /// </remarks>
- public AuthType AuthType {
- get {
- return _auth;
- }
- set {
- _auth = value;
- }
- }
- /// <summary>
- /// <ja>旈枾尞偺僼傽僀儖偱偡丅</ja>
- /// <en>Gets or sets the file name of the private key.</en>
- /// </summary>
- /// <remarks>
- /// <ja>僼儖僷僗偱巜掕偟偰偔偩偝偄丅</ja>
- /// <en>The full path is required.</en>
- /// </remarks>
- public string IdentityFile {
- get {
- return _identityfile;
- }
- set {
- _identityfile = value;
- }
- }
-
- /// <summary>
- /// <ja>僷僗儚乕僪傑偨偼僷僗僼儗乕僘偱偡丅</ja>
- /// <en>Gets or sets the password or the passphrase.</en>
- /// </summary>
- /// <remarks>
- /// <ja>岞奐尞擣徹偺応崌偼偙偺僾儘僷僥傿偺抣偑僷僗僼儗乕僘偲偟偰巊傢傟傑偡丅</ja>
- /// <en>In case of the public key authentication, the value of this property is used as the passphrase of the private key.</en>
- /// <ja>僷僗儚乕僪擣徹偺応崌偼僷僗儚乕僪偵側傝傑偡丅</ja>
- /// <en>In case of the password authentication, it is used as the login password.</en>
- /// </remarks>
- public string Passphrase {
- get {
- return _passphrase;
- }
- set {
- _passphrase = value;
- }
- }
- private static AuthType ParseAuth(string val) {
- if(val=="Password")
- return AuthType.Password;
- if(val=="PublicKey")
- return AuthType.PublicKey;
- if(val=="KeyboardInteractive")
- return AuthType.KeyboardInteractive;
- throw new FormatException(String.Format("{0} is unkown authentication option", val));
- }
- #if !MACRODOC
- public override sealed void Export(ConfigNode node) {
- base.Export(node);
- node["account"] = _account;
- node["auth"] = _auth.ToString();
- if(_auth==AuthType.PublicKey)
- node["keyfile"] = _identityfile;
- }
- public override void Import(ConfigNode data) {
- base.Import(data);
- _method = ParseMethod(data["method"]);
- Debug.Assert(this.IsSSH);
- _account = data["account"];
- _auth = ParseAuth(data["auth"]);
- if(_auth==AuthType.PublicKey)
- _identityfile = data["keyfile"];
- _passphrase = data["passphrase"];
- }
- public override string Description {
- get {
- string t;
- if(_account.Length > 0)
- t = _account + "@" + _host;
- else
- t = _host;
- return t;
- }
- }
- #endif
- }
- /// <summary>
- /// <ja>僼儘乕僐儞僩儘乕儖偺愝掕</ja>
- /// <en>Specifies the flow control.</en>
- /// </summary>
- [EnumDesc(typeof(FlowControl))]
- public enum FlowControl {
- /// <summary>
- /// <ja>側偟</ja>
- /// <en>None</en>
- /// </summary>
- [EnumValue(Description="Enum.FlowControl.None")] None,
- /// <summary>
- /// X ON / X OFf
- /// </summary>
- [EnumValue(Description="Enum.FlowControl.Xon_Xoff")] Xon_Xoff,
- /// <summary>
- /// <ja>僴乕僪僂僃傾</ja>
- /// <en>Hardware</en>
- /// </summary>
- [EnumValue(Description="Enum.FlowControl.Hardware")] Hardware
- }
- /// <summary>
- /// <ja>僷儕僥傿偺愝掕</ja>
- /// <en>Specifies the parity.</en>
- /// </summary>
- [EnumDesc(typeof(Parity))]
- public enum Parity {
- /// <summary>
- /// <ja>側偟</ja>
- /// <en>None</en>
- /// </summary>
- [EnumValue(Description="Enum.Parity.NOPARITY")] NOPARITY = 0,
- /// <summary>
- /// <ja>婏悢</ja>
- /// <en>Odd</en>
- /// </summary>
- [EnumValue(Description="Enum.Parity.ODDPARITY")] ODDPARITY = 1,
- /// <summary>
- /// <ja>嬼悢</ja>
- /// <en>Even</en>
- /// </summary>
- [EnumValue(Description="Enum.Parity.EVENPARITY")] EVENPARITY = 2
- //MARKPARITY = 3,
- //SPACEPARITY = 4
- }
- /// <summary>
- /// <ja>僗僩僢僾價僢僩偺愝掕</ja>
- /// <en>Specifies the stop bits.</en>
- /// </summary>
- [EnumDesc(typeof(StopBits))]
- public enum StopBits {
- /// <summary>
- /// <ja>1價僢僩</ja>
- /// <en>1 bit</en>
- /// </summary>
- [EnumValue(Description="Enum.StopBits.ONESTOPBIT")] ONESTOPBIT = 0,
- /// <summary>
- /// <ja>1.5價僢僩</ja>
- /// <en>1.5 bits</en>
- /// </summary>
- [EnumValue(Description="Enum.StopBits.ONE5STOPBITS")] ONE5STOPBITS= 1,
- /// <summary>
- /// <ja>2價僢僩</ja>
- /// <en>2 bits</en>
- /// </summary>
- [EnumValue(Description="Enum.StopBits.TWOSTOPBITS")] TWOSTOPBITS = 2
- }
- /// <summary>
- /// <ja>僔儕傾儖愙懕偺僷儔儊乕僞傪帵偟傑偡丅</ja>
- /// <en>Implements the parameters of serial connections.</en>
- /// </summary>
- [Serializable()]
- public class SerialTerminalParam : TerminalParam {
- internal int _port;
- internal int _baudRate;
- internal byte _byteSize; //7,8偺偳偪傜偐
- internal Parity _parity; //Win32僋儔僗撪偺掕悢偺偄偢傟偐
- internal StopBits _stopBits; //Win32僋儔僗撪偺掕悢偺偄偢傟偐
- internal FlowControl _flowControl;
- internal int _transmitDelayPerChar;
- internal int _transmitDelayPerLine;
- /// <summary>
- /// <ja>僨僼僅儖僩愝掕偱弶婜壔偟傑偡丅</ja>
- /// <en>Initializes with default values.</en>
- /// <seealso cref="Poderosa.Macro.ConnectionList.Open"/>
- /// </summary>
- /// <remarks>
- /// <ja>僷儔儊乕僞偼師偺傛偆偵弶婜壔偝傟傑偡丅</ja>
- /// <en>The parameters are set as following:</en>
- /// <list type="table">
- /// <item><term><ja>僄儞僐乕僨傿儞僌</ja><en>Encoding</en></term><description><ja>EUC-JP</ja><en>iso-8859-1</en></description></item>丂
- /// <item><term><ja>儘僌</ja><en>Log</en></term><description><ja>庢摼偟側偄</ja><en>None</en></description></item>丂丂丂丂丂丂丂
- /// <item><term><ja>儘乕僇儖僄僐乕</ja><en>Local echo</en></term><description><ja>偟側偄</ja><en>Don't</en></description></item>丂丂
- /// <item><term><ja>憲怣帪夵峴</ja><en>New line</en></term><description>CR</description></item>丂丂丂丂
- /// <item><term><ja>億乕僩</ja><en>Port</en></term><description>COM1</description></item>
- /// <item><term><ja>儃乕儗乕僩</ja><en>Baud Rate</en></term><description>9600</description></item>
- /// <item><term><ja>僨乕僞</ja><en>Data Bits</en></term><description><ja>8價僢僩</ja><en>8 bits</en></description></item>
- /// <item><term><ja>僷儕僥傿</ja><en>Parity</en></term><description><ja>側偟</ja><en>None</en></description></item>
- /// <item><term><ja>僗僩僢僾價僢僩</ja><en>Stop Bits</en></term><description><ja>侾價僢僩</ja><en>1 bit</en></description></item>
- /// <item><term><ja>僼儘乕僐儞僩儘乕儖</ja><en>Flow Control</en></term><description><ja>側偟</ja><en>None</en></description></item>
- /// </list>
- /// <ja>愙懕傪奐偔偵偼丄<see cref="Poderosa.Macro.ConnectionList.Open"/>儊僜僢僪偺堷悢偲偟偰SerialTerminalParam僆僽僕僃僋僩傪搉偟傑偡丅</ja>
- /// <en>To open a new connection, pass the SerialTerminalParam object to the <see cref="Poderosa.Macro.ConnectionList.Open"/> method.</en>
- /// </remarks>
- public SerialTerminalParam() {
- _port = 1;
- _baudRate = 9600;
- _byteSize = 8;
- _parity = Parity.NOPARITY;
- _stopBits = StopBits.ONESTOPBIT;
- _flowControl = FlowControl.None;
- }
- internal SerialTerminalParam(SerialTerminalParam p) : base(p) {
- _port = p._port;
- _baudRate = p._baudRate;
- _byteSize = p._byteSize;
- _parity = p._parity;
- _stopBits = p._stopBits;
- _flowControl = p._flowControl;
- _transmitDelayPerChar = p._transmitDelayPerChar;
- _transmitDelayPerLine = p._transmitDelayPerLine;
- }
- ///
- ///
- ///
- public override object Clone() {
- return new SerialTerminalParam(this);
- }
- ///
- ///
- ///
- public override bool Equals(object t_) {
- SerialTerminalParam t = t_ as SerialTerminalParam;
- if(t==null) return false;
- return base.Equals(t) && _port==t.Port && _baudRate==t.BaudRate && _byteSize==t.ByteSize && _parity==t.Parity && _stopBits==t.StopBits && _flowControl==t.FlowControl;
- }
- ///
- ///
- ///
- public override int GetHashCode() {
- return base.GetHashCode() + _port.GetHashCode()*2 + _baudRate.GetHashCode()*3 + _byteSize.GetHashCode()*4 + _parity.GetHashCode()*5 + _stopBits.GetHashCode()*6 + _flowControl.GetHashCode()*7;
- }
- #if !MACRODOC
- public override sealed void Export(ConfigNode node) {
- node["type"] = "serial";
- node["port"] = _port.ToString();
- node["baud-rate"] = _baudRate.ToString();
- node["byte-size"] = _byteSize.ToString();
- node["parity"] = EnumDescAttribute.For(typeof(Parity)).GetName(_parity);
- node["stop-bits"] = EnumDescAttribute.For(typeof(StopBits)).GetName(_stopBits);
- node["flow-control"] = EnumDescAttribute.For(typeof(FlowControl)).GetName(_flowControl);
- node["delay-per-char"] = _transmitDelayPerChar.ToString();
- node["delay-per-line"] = _transmitDelayPerLine.ToString();
- base.Export(node);
- }
- public override sealed void Import(ConfigNode data) {
- _port = GUtil.ParseInt(data["port"], 1);
- _baudRate = GUtil.ParseInt(data["baud-rate"], 9600);
- _byteSize = GUtil.ParseByte(data["byte-size"], 8);
- _parity = (Parity)EnumDescAttribute.For(typeof(Parity)).FromName(data["parity"], Parity.NOPARITY);
- _stopBits = (StopBits)EnumDescAttribute.For(typeof(StopBits)).FromName(data["stop-bits"], StopBits.ONESTOPBIT);
- _flowControl = (FlowControl)EnumDescAttribute.For(typeof(FlowControl)).FromName(data["flow-control"], FlowControl.None);
- _transmitDelayPerChar = GUtil.ParseInt(data["delay-per-char"], 0);
- _transmitDelayPerLine = GUtil.ParseInt(data["delay-per-line"], 0);
- base.Import(data);
- }
- public override string ShortDescription {
- get {
- return "COM"+_port;
- }
- }
- public override string Description {
- get {
- string t = "COM" + _port;
- return t;
- }
- }
- public override string MethodName {
- get {
- return "serial";
- }
- }
- #endif
- /// <summary>
- /// <ja>億乕僩偱偡丅</ja>
- /// <en>Gets or sets the port.</en>
- /// </summary>
- /// <remarks>
- /// <ja>侾側傜COM1丄10側傜COM10偵側傝傑偡丅</ja>
- /// <en>1 means COM1, and 10 means COM10.</en>
- /// </remarks>
- public int Port {
- get {
- return _port;
- }
- set {
- _port = value;
- }
- }
- /// <summary>
- /// <ja>儃乕儗乕僩偱偡丅</ja>
- /// <en>Gets or sets the baud rate.</en>
- /// </summary>
- public int BaudRate {
- get {
- return _baudRate;
- }
- set {
- _baudRate = value;
- }
- }
- /// <summary>
- /// <ja>僨乕僞偺價僢僩悢偱偡丅</ja>
- /// <en>Gets or sets the bit count of the data.</en>
- /// </summary>
- /// <remarks>
- /// <ja>俈偐俉偱側偄偲偄偗傑偣傫丅</ja>
- /// <en>The value must be 7 or 8.</en>
- /// </remarks>
- public byte ByteSize {
- get {
- return _byteSize;
- }
- set {
- _byteSize = value;
- }
- }
- /// <summary>
- /// <ja>僷儕僥傿偱偡丅</ja>
- /// <en>Gets or sets the parity.</en>
- /// </summary>
- public Parity Parity {
- get {
- return _parity;
- }
- set {
- _parity = value;
- }
- }
- /// <summary>
- /// <ja>僗僩僢僾價僢僩偱偡丅</ja>
- /// <en>Gets or sets the stop bit.</en>
- /// </summary>
- public StopBits StopBits {
- get {
- return _stopBits;
- }
- set {
- _stopBits = value;
- }
- }
- /// <summary>
- /// <ja>僼儘乕僐儞僩儘乕儖偱偡丅</ja>
- /// <en>Gets or sets the flow control.</en>
- /// </summary>
- public FlowControl FlowControl {
- get {
- return _flowControl;
- }
- set {
- _flowControl = value;
- }
- }
- /// <summary>
- /// <ja>暥帤偁偨傝偺僨傿儗僀(儈儕昩扨埵)偱偡丅</ja>
- /// <en>Gets or sets the delay time per a character in milliseconds.</en>
- /// </summary>
- public int TransmitDelayPerChar {
- get {
- return _transmitDelayPerChar;
- }
- set {
- #if !MACRODOC
- if(value<0) throw new ArgumentException(GEnv.Strings.GetString("Message.SerialPTerminalParam.TransmitDelayRange"));
- _transmitDelayPerChar = value;
- #endif
- }
- }
- /// <summary>
- /// <ja>峴偁偨傝偺僨傿儗僀(儈儕昩扨埵)偱偡丅</ja>
- /// <en>Gets or sets the delay time per a line in milliseconds.</en>
- /// </summary>
- public int TransmitDelayPerLine {
- get {
- return _transmitDelayPerLine;
- }
- set {
- #if !MACRODOC
- if(value<0) throw new ArgumentException(GEnv.Strings.GetString("Message.SerialPTerminalParam.TransmitDelayRange"));
- _transmitDelayPerLine = value;
- #endif
- }
- }
- }
- /// <summary>
- /// <ja>Cygwin傑偨偼Services for Unix偵愙懕偡傞偨傔偺TerminalParam偱偡丅</ja>
- /// <en>Implements the parameters to connect a cygwin shell or a Services for Unix shell.</en>
- /// </summary>
- public abstract class LocalShellTerminalParam : TerminalParam {
- protected string _home;
- protected string _shell;
- /// <summary>
- /// <ja>昗弨揑側抣偱弶婜壔偟傑偡丅</ja>
- /// <en>Initializes with default values.</en>
- /// </summary>
- public LocalShellTerminalParam() {
- #if !MACRODOC
- _terminalType = TerminalType.VT100;
- _transmitnl = NewLine.CR;
- _encoding = LocalShellUtil.DefaultEncoding;
- #endif
- }
- internal LocalShellTerminalParam(LocalShellTerminalParam p) : base(p) {
- _home = p._home;
- _shell = p._shell;
- }
- /// <summary>
- /// <ja>Cygwin忋偺僔僃儖偵偮側偄偩偲偒偺HOME娐嫬曄悢偺抣偱偡丅僨僼僅儖僩抣偼 <c>/home/(Windows偺傾僇僂儞僩柤)</c> 偱偡丅</ja>
- /// <en>Gets or sets the initial value of the HOME environment variable. The default value is <c>/home/(account name on Windows)</c>.</en>
- /// </summary>
- public string Home {
- get {
- return _home;
- }
- set {
- _home = value;
- }
- }
- /// <summary>
- /// <ja>婲摦偡傞Cygwin偺僔僃儖傊偺僷僗偱偡丅僨僼僅儖僩抣偼 <c>/bin/bash</c> 偱偡丅</ja>
- /// <en>Gets or sets the path of the shell. The defualt value is <c>/bin/bash</c>.</en>
- /// </summary>
- public string Shell {
- get {
- return _shell;
- }
- set {
- _shell = value;
- }
- }
- #if !MACRODOC
- public override void Import(ConfigNode data) {
- _home = data["home"];
- _shell = data["shell"];
- base.Import(data);
- }
- public override string ShortDescription {
- get {
- int n = _shell.IndexOf(' ');
- return n==-1? _shell : _shell.Substring(0, n);
- }
- }
- #endif
- }
- /// <summary>
- /// <ja>Cygwin偵愙懕偡傞偨傔偺TerminalParam偱偡丅</ja>
- /// <en>Implements the parameters to connect a cygwin shell.</en>
- /// </summary>
- public class CygwinTerminalParam : LocalShellTerminalParam {
- public CygwinTerminalParam() {
- #if !MACRODOC
- _home = CygwinUtil.DefaultHome;
- _shell = CygwinUtil.DefaultShell;
- #endif
- }
- public override object Clone() {
- CygwinTerminalParam p = new CygwinTerminalParam();
- p.Home = _home;
- p.Shell = _shell;
- return p;
- }
- public override bool Equals(object t_) {
- CygwinTerminalParam t = t_ as CygwinTerminalParam;
- if(t==null) return false;
- return base.Equals(t) && _home==t._home && _shell==t._shell;
- }
- public override int GetHashCode() {
- return base.GetHashCode() + _home.GetHashCode()*3 + _shell.GetHashCode()*7;
- }
- #if !MACRODOC
- public override sealed void Export(ConfigNode node) {
- node["type"] = "cygwin";
- node["home"] = _home;
- node["shell"] = _shell;
- base.Export(node);
- }
- public override string Description {
- get {
- return ShortDescription + "(cygwin)";
- }
- }
- public override string MethodName {
- get {
- return "cygwin";
- }
- }
- #endif
- }
- /// <summary>
- /// <ja>Services for Unix偵愙懕偡傞偨傔偺TerminalParam偱偡丅</ja>
- /// <en>Implements the parameters to connect a shell of Servies for Unix.</en>
- /// </summary>
- public class SFUTerminalParam : LocalShellTerminalParam {
- public SFUTerminalParam() {
- #if !MACRODOC
- _home = SFUUtil.DefaultHome;
- _shell = SFUUtil.DefaultShell;
- #endif
- }
- public override object Clone() {
- SFUTerminalParam p = new SFUTerminalParam();
- p.Home = _home;
- p.Shell = _shell;
- return p;
- }
- public override bool Equals(object t_) {
- SFUTerminalParam t = t_ as SFUTerminalParam;
- if(t==null) return false;
- return base.Equals(t) && _home==t._home && _shell==t._shell;
- }
- public override int GetHashCode() {
- return base.GetHashCode() + _home.GetHashCode()*3 + _shell.GetHashCode()*7;
- }
- #if !MACRODOC
- public override sealed void Export(ConfigNode node) {
- node["type"] = "sfu";
- node["home"] = _home;
- node["shell"] = _shell;
- base.Export(node);
- }
- public override string Description {
- get {
- return ShortDescription + "(SFU)";
- }
- }
- public override string MethodName {
- get {
- return "SFU";
- }
- }
- #endif
- }
- }