public void SwitchTo(ProfileInfo profile) { var options = ToxOptions.Default; options.Ipv6Enabled = Config.Instance.EnableIpv6; if (Config.Instance.ProxyType != ToxProxyType.None) { options.UdpEnabled = false; options.ProxyType = Config.Instance.ProxyType; options.ProxyHost = Config.Instance.ProxyAddress; options.ProxyPort = Config.Instance.ProxyPort; } else { options.UdpEnabled = Config.Instance.EnableUdp; } Tox newTox; if (profile != null) { var data = ToxData.FromDisk(profile.Path); if (data == null) { throw new Exception("Could not load profile."); } if (data.IsEncrypted) { throw new Exception("Data is encrypted, Toxy does not support encrypted profiles yet."); } newTox = new Tox(options, data); } else { newTox = new Tox(options); } var newToxAv = new ToxAv(newTox); InitManagers(newTox, newToxAv); if (Tox != null) { Tox.Dispose(); } if (ToxAv != null) { ToxAv.Dispose(); } Tox = newTox; ToxAv = newToxAv; AvatarManager.Rehash(); ConnectionManager.DoBootstrap(); //TODO: move this someplace else and make it configurable if (string.IsNullOrEmpty(Tox.Name)) { Tox.Name = "Tox User"; } if (string.IsNullOrEmpty(Tox.StatusMessage)) { Tox.StatusMessage = "Toxing on Toxy"; } Tox.Start(); ToxAv.Start(); CurrentProfile = profile; MainWindow.Instance.Reload(); }
public void Start() { _toxAv.Start(); }