Exemple #1
0
        private static void LoadEnv() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled;

            string error_msg = null;
            ReloadStringResource();
            _channels = new ChannelProfileCollection();
            _options = new Options();

            _globalMutex = Win32.CreateMutex(IntPtr.Zero, 0, "PoderosaPFGlobalMutex");
            bool already_exists = (Win32.GetLastError() == Win32.ERROR_ALREADY_EXISTS);
            if (_globalMutex == IntPtr.Zero)
                throw new Exception("Global mutex could not open");
            if (Win32.WaitForSingleObject(_globalMutex, 10000) != Win32.WAIT_OBJECT_0)
                throw new Exception("Global mutex lock error");

            try {
                OptionPreservePlace place = GetOptionPreservePlace();
                _options.OptionPreservePlace = place;
                string dir = GetOptionDirectory(place);
                if (!Directory.Exists(dir))
                    Directory.CreateDirectory(dir);
                string configfile = dir + "portforwarding.conf";
                bool options_loaded = false;
                try {
                    if (File.Exists(configfile)) {
                        Encoding encoding = DetermineConfigFileEncoding(configfile);
                        using (TextReader reader = new StreamReader(File.Open(configfile, FileMode.Open, FileAccess.Read), encoding)) {
                            ConfigNode parent = new ConfigNode("root", reader).FindChildConfigNode("poderosa-portforwarding");
                            if (parent != null) {
                                _channels.Load(parent);
                                _options.Load(parent);
                                options_loaded = true;
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    error_msg = ex.Message;
                }
                finally {
                    if (!options_loaded)
                        _options.Init();
                }

                //ここまできたら言語設定をチェックし、必要なら読み直し
                if (Util.CurrentLanguage != _options.Language) {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = _options.Language == Language.Japanese ? new CultureInfo("ja") : CultureInfo.InvariantCulture;
                }

                _log = new ConnectionLog(dir + "portforwarding.log");
            }
            finally {
                Win32.ReleaseMutex(_globalMutex);
            }
        }
Exemple #2
0
 public static void UpdateOptions(Options opt)
 {
     _form.ShowInTaskbar = opt.ShowInTaskBar;
     if (_options.Language != opt.Language) { //言語のリロードが必要なとき
         System.Threading.Thread.CurrentThread.CurrentUICulture = opt.Language == Language.Japanese ? new CultureInfo("ja") : CultureInfo.InvariantCulture;
         ReloadStringResource();
         _form.ReloadLanguage();
     }
     _options = opt;
 }
Exemple #3
0
        private void OptionDialog_Load(object sender, System.EventArgs args)
        {
            _options = (Options)Env.Options.Clone();

            //SSH
            string[] co = _options.CipherAlgorithmOrder;
            foreach(string c in co)
                _cipherOrderList.Items.Add(c);
            _hostKeyBox.SelectedIndex = SSHUtil.ParsePublicKeyAlgorithm(_options.HostKeyAlgorithmOrder[0])==PublicKeyAlgorithm.DSA? 0 : 1; //�����DSA/RSA�̂ǂ��炩�����Ȃ�
            _windowSizeBox.Text = _options.SSHWindowSize.ToString();
            _retainsPassphrase.Checked = _options.RetainsPassphrase;
            _sshCheckMAC.Checked = _options.SSHCheckMAC;

            //�ڑ�
            _useSocks.Checked = _options.UseSocks;
            _socksServerBox.Text = _options.SocksServer;
            _socksPortBox.Text = _options.SocksPort.ToString();
            _socksAccountBox.Text = _options.SocksAccount;
            _socksPasswordBox.Text = _options.SocksPassword;
            _socksNANetworksBox.Text = _options.SocksNANetworks;

            //���
            _showInTaskBarOption.Checked = _options.ShowInTaskBar;
            _warningOnExit.Checked = _options.WarningOnExit;
            _optionPreservePlace.SelectedIndex = (int)_options.OptionPreservePlace;
            _languageBox.SelectedIndex = (int)_options.Language;
        }
Exemple #4
0
        public object Clone() {
            Options opt = new Options();
            opt._framePosition = _framePosition;
            opt._frameState = _frameState;
            opt._showInTaskBar = _showInTaskBar;
            opt._warningOnExit = _warningOnExit;
            opt._optionPreservePlace = _optionPreservePlace;
            opt._envLanguage = _envLanguage;
            opt._language = _language;

            opt._cipherAlgorithmOrder = (string[])_cipherAlgorithmOrder.Clone();
            opt._hostKeyAlgorithmOrder = (string[])_hostKeyAlgorithmOrder.Clone();
            opt._sshWindowSize = _sshWindowSize;
            opt._retainsPassphrase = _retainsPassphrase;
            opt._sshCheckMAC = _sshCheckMAC;

            opt._useSocks = _useSocks;
            opt._socksServer = _socksServer;
            opt._socksPort = _socksPort;
            opt._socksAccount = _socksAccount;
            opt._socksPassword = _socksPassword;
            opt._socksNANetworks = _socksNANetworks;

            return opt;
        }
Exemple #5
0
        private static void LoadEnv()
        {
            string error_msg = null;
            ReloadStringResource();
            _channels = new ChannelProfileCollection();
            _options = new Options();
            ThemeUtil.Init();

            _globalMutex = Win32.CreateMutex(IntPtr.Zero, 0, "PoderosaPFGlobalMutex");
            bool already_exists = (Win32.GetLastError()==Win32.ERROR_ALREADY_EXISTS);
            if(_globalMutex==IntPtr.Zero) throw new Exception("Global mutex could not open");
            if(Win32.WaitForSingleObject(_globalMutex, 10000)!=Win32.WAIT_OBJECT_0) throw new Exception("Global mutex lock error");

            try {
                OptionPreservePlace place = GetOptionPreservePlace();
                _options.OptionPreservePlace = place;
                string dir = GetOptionDirectory(place);
                if(!Directory.Exists(dir)) Directory.CreateDirectory(dir);
                string configfile = dir + "portforwarding.conf";
                bool options_loaded = false;
                TextReader reader = null;
                try {
                    if(File.Exists(configfile)) {
                        reader = new StreamReader(File.Open(configfile, FileMode.Open, FileAccess.Read), Encoding.Default);
                        ConfigNode parent = new ConfigNode("root", reader).FindChildConfigNode("poderosa-portforwarding");
                        if(parent!=null) {
                            _channels.Load(parent);
                            _options.Load(parent);
                            options_loaded = true;
                        }
                    }
                }
                catch(Exception ex) {
                    error_msg = ex.Message;
                }
                finally {
                    if(reader!=null) reader.Close();
                    if(!options_loaded) _options.Init();
                }

                //�����܂ł����猾��ݒ��`�F�b�N���A�K�v�Ȃ�ǂݒ���
                if(Util.CurrentLanguage!=_options.Language) {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = _options.Language==Language.Japanese? new CultureInfo("ja") : CultureInfo.InvariantCulture;
                }

                _log = new ConnectionLog(dir + "portforwarding.log");
            }
            finally {
                Win32.ReleaseMutex(_globalMutex);
            }
        }
Exemple #6
0
 public static void UpdateOptions(Options opt)
 {
     _form.ShowInTaskbar = opt.ShowInTaskBar;
     if(_options.Language!=opt.Language) { //����̃����[�h���K�v�ȂƂ�
         System.Threading.Thread.CurrentThread.CurrentUICulture = opt.Language==Language.Japanese? new CultureInfo("ja") : CultureInfo.InvariantCulture;
         ReloadStringResource();
         _form.ReloadLanguage();
         Granados.SSHC.Strings.Reload();
     }
     _options = opt;
 }