public override NSObject GetObjectValue(NSTableView tableView, NSTableColumn tableColumn, int row) { TableRoutingControllerItem i = Items [row]; if (tableColumn.Identifier == "Icon") { if (i.Icon == "in") { return(NSImage.ImageNamed("routes_in.png")); } else { return(NSImage.ImageNamed("routes_out.png")); } } else if (tableColumn.Identifier == "Ip") { return(new NSString(i.Ip)); } else if (tableColumn.Identifier == "Action") { return(new NSString(WindowPreferencesController.RouteDirectionToDescription(i.Action))); } else if (tableColumn.Identifier == "Notes") { return(new NSString(i.Notes)); } else { throw new NotImplementedException(string.Format("{0} is not recognized", tableColumn.Identifier)); } }
void RouteEdit() { int i = TableRoutes.SelectedRow; if (i != -1) { TableRoutingControllerItem item = TableRoutingController.Items [i]; WindowPreferencesRouteController.Item = item; WindowPreferencesRouteController dlg = new WindowPreferencesRouteController(); dlg.Window.ReleasedWhenClosed = true; NSApplication.SharedApplication.RunModalForWindow(dlg.Window); dlg.Window.Close(); TableRoutingController.RefreshUI(); this.EnableIde(); } }
void RouteAdd() { TableRoutingControllerItem item = new TableRoutingControllerItem(); item.Ip = ""; item.Icon = "out"; item.Action = "out"; item.Notes = ""; WindowPreferencesRouteController.Item = item; WindowPreferencesRouteController dlg = new WindowPreferencesRouteController(); dlg.Window.ReleasedWhenClosed = true; NSApplication.SharedApplication.RunModalForWindow(dlg.Window); dlg.Window.Close(); if (dlg.Accepted) { TableRoutingController.Items.Add(item); TableRoutingController.RefreshUI(); } this.EnableIde(); }
void ReadOptions() { Storage s = Engine.Instance.Storage; // General GuiUtils.SetCheck(ChkAutoStart, s.GetBool("connect")); GuiUtils.SetCheck(ChkGeneralStartLast, s.GetBool("servers.startlast")); GuiUtils.SetCheck(ChkGeneralOsxVisible, s.GetBool("gui.osx.visible")); // GuiUtils.SetCheck (ChkGeneralOsxDock, s.GetBool ("gui.osx.dock")); // See this FAQ: https://airvpn.org/topic/13331-its-possible-to-hide-the-icon-in-dock-bar-under-os-x/ GuiUtils.SetCheck(ChkGeneralOsxNotifications, s.GetBool("gui.osx.notifications")); GuiUtils.SetCheck(ChkExitConfirm, s.GetBool("gui.exit_confirm")); /* * string interfaceMode = GuiUtils.InterfaceColorMode (); * if (interfaceMode == "Dark") * GuiUtils.SetSelected (CboGeneralOsxInterfaceStyle,"Dark"); * else * GuiUtils.SetSelected (CboGeneralOsxInterfaceStyle,"Default"); */ // Mode m_mode_protocol = s.Get("mode.protocol").ToUpperInvariant(); m_mode_port = s.GetInt("mode.port"); m_mode_alternate = s.GetInt("mode.alt"); ChangeMode(); TxtModeTorHost.StringValue = s.Get("mode.tor.host"); TxtModeTorPort.StringValue = s.Get("mode.tor.port"); TxtModeTorControlPort.StringValue = s.Get("mode.tor.control.port"); TxtModeTorControlPassword.StringValue = s.Get("mode.tor.control.password"); // Proxy GuiUtils.SetSelected(CboProxyType, s.Get("proxy.mode")); TxtProxyHost.StringValue = s.Get("proxy.host"); TxtProxyPort.StringValue = s.Get("proxy.port"); GuiUtils.SetSelected(CboProxyAuthentication, s.Get("proxy.auth")); TxtProxyLogin.StringValue = s.Get("proxy.login"); TxtProxyPassword.StringValue = s.Get("proxy.password"); // Routes GuiUtils.SetSelected(CboRoutesOtherwise, RouteDirectionToDescription(s.Get("routes.default"))); string routes = s.Get("routes.custom"); string[] routes2 = routes.Split(';'); foreach (string route in routes2) { string[] routeEntries = route.Split(','); if (routeEntries.Length < 2) { continue; } TableRoutingControllerItem item = new TableRoutingControllerItem(); item.Ip = routeEntries [0]; item.Action = routeEntries [1]; item.Icon = routeEntries [1]; if (routeEntries.Length == 3) { item.Notes = routeEntries [2]; } TableRoutingController.Items.Add(item); } TableRoutingController.RefreshUI(); // Advanced GuiUtils.SetCheck(ChkAdvancedExpertMode, s.GetBool("advanced.expert")); GuiUtils.SetCheck(ChkAdvancedCheckDns, s.GetBool("advanced.check.dns")); GuiUtils.SetCheck(ChkAdvancedCheckRoute, s.GetBool("advanced.check.route")); string dnsMode = s.Get("advanced.dns.mode"); if (dnsMode == "none") { GuiUtils.SetSelected(CboAdvancedDnsSwitchMode, "Disabled"); } else { GuiUtils.SetSelected(CboAdvancedDnsSwitchMode, "Automatic"); } GuiUtils.SetCheck(ChkAdvancedPingerEnabled, s.GetBool("advanced.pinger.enabled")); GuiUtils.SetCheck(ChkAdvancedPingerAlways, s.GetBool("advanced.pinger.always")); TxtAdvancedOpenVpnPath.StringValue = s.Get("executables.openvpn"); int manifestRefresh = s.GetInt("advanced.manifest.refresh"); if (manifestRefresh == 60) { GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every one hour"); } else if (manifestRefresh == 10) { GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every ten minute"); } else if (manifestRefresh == 1) { GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every minute"); } else if (manifestRefresh == 0) { GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Never"); } else { GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Automatic"); } // Advanced - Lock string lockMode = s.Get("netlock.mode"); GuiUtils.SetSelected(CboLockMode, "None"); if (lockMode == "auto") { GuiUtils.SetSelected(CboLockMode, "Automatic"); } else { foreach (NetworkLockPlugin lockPlugin in Engine.Instance.NetworkLockManager.Modes) { if (lockPlugin.GetCode() == lockMode) { GuiUtils.SetSelected(CboLockMode, lockPlugin.GetName()); } } } TxtLockAllowedIPS.StringValue = s.Get("netlock.allowed_ips"); // Advanced - Logging GuiUtils.SetCheck(ChkLoggingEnabled, s.GetBool("log.file.enabled")); TxtLoggingPath.StringValue = s.Get("log.file.path"); // Advanced - OVPN Directives GuiUtils.SetCheck(ChkAdvancedOpenVpnDirectivesDefaultSkip, s.GetBool("openvpn.skip_defaults")); TxtAdvancedOpenVpnDirectivesCustom.StringValue = s.Get("openvpn.custom"); TxtAdvancedOpenVpnDirectivesDefault.StringValue = s.GetDefaultDirectives().Replace("\t", ""); // Advanced - Events ReadOptionsEvent("app.start", 0); ReadOptionsEvent("app.stop", 1); ReadOptionsEvent("session.start", 2); ReadOptionsEvent("session.stop", 3); ReadOptionsEvent("vpn.pre", 4); ReadOptionsEvent("vpn.up", 5); ReadOptionsEvent("vpn.down", 6); TableAdvancedEventsController.RefreshUI(); }
void ReadOptions() { Storage s = Engine.Instance.Storage; // General GuiUtils.SetCheck (ChkConnect, s.GetBool ("connect")); GuiUtils.SetCheck (ChkNetLock, s.GetBool ("netlock")); GuiUtils.SetCheck (ChkGeneralStartLast, s.GetBool("servers.startlast")); GuiUtils.SetCheck (ChkGeneralOsxVisible, s.GetBool ("gui.osx.visible")); // GuiUtils.SetCheck (ChkGeneralOsxDock, s.GetBool ("gui.osx.dock")); // See this FAQ: https://airvpn.org/topic/13331-its-possible-to-hide-the-icon-in-dock-bar-under-os-x/ GuiUtils.SetCheck (ChkGeneralOsxNotifications, s.GetBool ("gui.osx.notifications")); GuiUtils.SetCheck (ChkExitConfirm, s.GetBool("gui.exit_confirm")); /* string interfaceMode = GuiUtils.InterfaceColorMode (); if (interfaceMode == "Dark") GuiUtils.SetSelected (CboGeneralOsxInterfaceStyle,"Dark"); else GuiUtils.SetSelected (CboGeneralOsxInterfaceStyle,"Default"); */ // Mode m_mode_protocol = s.Get ("mode.protocol").ToUpperInvariant (); m_mode_port = s.GetInt ("mode.port"); m_mode_alternate = s.GetInt ("mode.alt"); ChangeMode (); TxtModeTorHost.StringValue = s.Get ("mode.tor.host"); TxtModeTorPort.StringValue = s.Get ("mode.tor.port"); TxtModeTorControlPort.StringValue = s.Get ("mode.tor.control.port"); TxtModeTorControlPassword.StringValue = s.Get ("mode.tor.control.password"); // Proxy GuiUtils.SetSelected (CboProxyType, s.Get("proxy.mode")); TxtProxyHost.StringValue = s.Get ("proxy.host"); TxtProxyPort.StringValue = s.Get ("proxy.port"); GuiUtils.SetSelected (CboProxyAuthentication, s.Get ("proxy.auth")); TxtProxyLogin.StringValue = s.Get ("proxy.login"); TxtProxyPassword.StringValue = s.Get ("proxy.password"); // Routes GuiUtils.SetSelected(CboRoutesOtherwise, RouteDirectionToDescription(s.Get("routes.default"))); string routes = s.Get ("routes.custom"); string[] routes2 = routes.Split (';'); foreach (string route in routes2) { string[] routeEntries = route.Split (','); if (routeEntries.Length < 2) continue; TableRoutingControllerItem item = new TableRoutingControllerItem (); item.Ip = routeEntries [0]; item.Action = routeEntries [1]; item.Icon = routeEntries [1]; if(routeEntries.Length == 3) item.Notes = routeEntries [2]; TableRoutingController.Items.Add (item); } TableRoutingController.RefreshUI(); // Advanced - General GuiUtils.SetCheck (ChkAdvancedExpertMode, s.GetBool ("advanced.expert")); GuiUtils.SetCheck (ChkAdvancedCheckRoute, s.GetBool ("advanced.check.route")); string ipV6Mode = s.Get ("ipv6.mode"); if (ipV6Mode == "none") GuiUtils.SetSelected (CboIpV6, "None"); else if (ipV6Mode == "disable") GuiUtils.SetSelected (CboIpV6, "Disable"); else GuiUtils.SetSelected (CboIpV6, "None"); GuiUtils.SetCheck (ChkAdvancedPingerEnabled, s.GetBool ("advanced.pinger.enabled")); GuiUtils.SetCheck (ChkRouteRemoveDefaultGateway, s.GetBool("routes.remove_default")); TxtAdvancedOpenVpnPath.StringValue = s.Get ("executables.openvpn"); int manifestRefresh = s.GetInt("advanced.manifest.refresh"); if (manifestRefresh == 60) GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every one hour"); else if (manifestRefresh == 10) GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every ten minute"); else if (manifestRefresh == 1) GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every minute"); else if (manifestRefresh == 0) GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Never"); else GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Automatic"); int openVpnSndBuf = s.GetInt("openvpn.sndbuf"); if (openVpnSndBuf == -1) GuiUtils.SetSelected(CboOpenVpnSndBuf, Messages.WindowsSettingsOpenVpnDefault); else if (openVpnSndBuf == 1024 * 8) GuiUtils.SetSelected(CboOpenVpnSndBuf, "8 KB"); else if (openVpnSndBuf == 1024 * 16) GuiUtils.SetSelected(CboOpenVpnSndBuf, "16 KB"); else if (openVpnSndBuf == 1024 * 32) GuiUtils.SetSelected(CboOpenVpnSndBuf, "32 KB"); else if (openVpnSndBuf == 1024 * 64) GuiUtils.SetSelected(CboOpenVpnSndBuf, "64 KB"); else if (openVpnSndBuf == 1024 * 128) GuiUtils.SetSelected(CboOpenVpnSndBuf, "128 KB"); else if (openVpnSndBuf == 1024 * 256) GuiUtils.SetSelected(CboOpenVpnSndBuf, "256 KB"); else if (openVpnSndBuf == 1024 * 512) GuiUtils.SetSelected(CboOpenVpnSndBuf, "512 KB"); int openVpnRcvBuf = s.GetInt("openvpn.rcvbuf"); if (openVpnRcvBuf == -1) GuiUtils.SetSelected(CboOpenVpnRcvBuf, Messages.WindowsSettingsOpenVpnDefault); else if (openVpnRcvBuf == 1024 * 8) GuiUtils.SetSelected(CboOpenVpnRcvBuf, "8 KB"); else if (openVpnRcvBuf == 1024 * 16) GuiUtils.SetSelected(CboOpenVpnRcvBuf, "16 KB"); else if (openVpnRcvBuf == 1024 * 32) GuiUtils.SetSelected(CboOpenVpnRcvBuf, "32 KB"); else if (openVpnRcvBuf == 1024 * 64) GuiUtils.SetSelected(CboOpenVpnRcvBuf, "64 KB"); else if (openVpnRcvBuf == 1024 * 128) GuiUtils.SetSelected(CboOpenVpnRcvBuf, "128 KB"); else if (openVpnRcvBuf == 1024 * 256) GuiUtils.SetSelected(CboOpenVpnRcvBuf, "256 KB"); else if (openVpnRcvBuf == 1024 * 512) GuiUtils.SetSelected(CboOpenVpnRcvBuf, "512 KB"); // Advanced - DNS string dnsMode = s.Get ("dns.mode"); if (dnsMode == "none") GuiUtils.SetSelected (CboDnsSwitchMode, "Disabled"); else GuiUtils.SetSelected (CboDnsSwitchMode, "Automatic"); GuiUtils.SetCheck (ChkDnsCheck, s.GetBool ("dns.check")); TableDnsServersController.Clear (); string[] dnsServers = s.Get ("dns.servers").Split (','); foreach (string dnsServer in dnsServers) { if (Utils.IsIP (dnsServer)) TableDnsServersController.Add (dnsServer); } // Advanced - Lock string lockMode = s.Get ("netlock.mode"); GuiUtils.SetSelected (CboLockMode, "None"); if (lockMode == "auto") GuiUtils.SetSelected (CboLockMode, "Automatic"); else { foreach (NetworkLockPlugin lockPlugin in Engine.Instance.NetworkLockManager.Modes) { if (lockPlugin.GetCode () == lockMode) { GuiUtils.SetSelected(CboLockMode, lockPlugin.GetName()); } } } GuiUtils.SetCheck(ChkLockAllowPrivate, s.GetBool("netlock.allow_private")); GuiUtils.SetCheck(ChkLockAllowPing, s.GetBool("netlock.allow_ping")); TxtLockAllowedIPS.StringValue = s.Get("netlock.allowed_ips"); // Advanced - Logging GuiUtils.SetCheck (ChkLoggingEnabled, s.GetBool ("log.file.enabled")); GuiUtils.SetCheck (ChkLogLevelDebug, s.GetBool ("log.level.debug")); TxtLoggingPath.StringValue = s.Get ("log.file.path"); // Advanced - OVPN Directives GuiUtils.SetCheck (ChkAdvancedOpenVpnDirectivesDefaultSkip, s.GetBool ("openvpn.skip_defaults")); TxtAdvancedOpenVpnDirectivesCustom.StringValue = s.Get ("openvpn.custom"); TxtAdvancedOpenVpnDirectivesDefault.StringValue = s.GetDefaultDirectives ().Replace("\t",""); // Advanced - Events ReadOptionsEvent ("app.start", 0); ReadOptionsEvent ("app.stop", 1); ReadOptionsEvent ("session.start", 2); ReadOptionsEvent ("session.stop", 3); ReadOptionsEvent ("vpn.pre", 4); ReadOptionsEvent ("vpn.up", 5); ReadOptionsEvent ("vpn.down", 6); TableAdvancedEventsController.RefreshUI (); }
void RouteAdd() { TableRoutingControllerItem item = new TableRoutingControllerItem(); item.Ip = ""; item.Icon = "out"; item.Action = "out"; item.Notes = ""; WindowPreferencesRouteController.Item = item; WindowPreferencesRouteController dlg = new WindowPreferencesRouteController (); dlg.Window.ReleasedWhenClosed = true; NSApplication.SharedApplication.RunModalForWindow (dlg.Window); dlg.Window.Close (); if(dlg.Accepted) { TableRoutingController.Items.Add(item); TableRoutingController.RefreshUI (); } this.EnableIde(); }