public Task OnVpnStateChanged(VpnStateChangedEventArgs e) { if (_appSettings.UseTunAdapter && e.Error == VpnError.TapAdapterInUseError) { _modals.Show <TunInUseModalViewModel>(); return(Task.CompletedTask); } VpnStatus status = e.State.Status; if (ModalShouldBeShown(e)) { Post(() => ShowModal(e)); } else { if (status == VpnStatus.Connecting || status == VpnStatus.Connected || (status == VpnStatus.Disconnecting || status == VpnStatus.Disconnected) && e.Error == VpnError.None) { Post(CloseModal); _modalShowed = false; } } return(Task.CompletedTask); }
private async Task InvokeAction(Func <Task> action) { if (!_baseFilteringEngineService.Running()) { _modals.Show <BfeWarningModalViewModel>(); return; } while (true) { try { await action(); break; } catch (EndpointNotFoundException) { var result = _modals.Show <ServiceStartModalViewModel>(); if (result == null || !result.Value) { break; } } catch (Exception e) when(IsConnectionException(e)) { _logger.Error(e); } } }
public bool?ShowWarning(string message) { var settings = DialogSettings.FromMessage(message) .WithPrimaryButtonText(StringResources.Get("Dialogs_btn_Close")); _warningViewModel.ApplySettings(settings); return(_modals.Show <WarningModalViewModel>()); }
public async Task OnVpnStateChanged(VpnStateChangedEventArgs e) { if (_appSettings.NetworkAdapterType == OpenVpnAdapter.Tun && e.Error == VpnError.TapAdapterInUseError) { _modals.Show <TunInUseModalViewModel>(); return; } VpnStatus status = e.State.Status; switch (e.Error) { case VpnError.CertRevokedOrExpired: await _authCertificateManager.ForceRequestNewKeyPairAndCertificateAsync(); await _vpnManager.ReconnectAsync(new VpnReconnectionSettings { IsToReconnectIfDisconnected = true }); return; case VpnError.CertificateExpired when e.State.Status == VpnStatus.ActionRequired: _lastAuthCertificate = _appSettings.AuthenticationCertificatePem; await _authCertificateManager.ForceRequestNewCertificateAsync(); if (FailedToUpdateAuthCert()) { await _vpnManager.ReconnectAsync(new VpnReconnectionSettings { IsToReconnectIfDisconnected = true }); } else { await _vpnServiceManager.UpdateAuthCertificate(_appSettings.AuthenticationCertificatePem); } return; } if (ModalShouldBeShown(e)) { Post(() => ShowModalAsync(e)); } else { if (status == VpnStatus.Pinging || status == VpnStatus.Connecting || status == VpnStatus.Connected || (status == VpnStatus.Disconnecting || status == VpnStatus.Disconnected) && e.Error == VpnError.None) { Post(CloseModalAsync); } } }
private void ShowEnjoyModal() { var rand = new Random(); var randomNumber = rand.Next(0, 100); if (randomNumber >= 15) { return; } _modals.Show <EnjoyingUpsellModalViewModel>(); }
private VpnReconnectionSteps CalculateSimilarOnAutoProtocolReconnectionStep() { if (_appSettings.DoNotShowEnableSmartProtocolDialog || _appSettings.GetProtocol() == VpnProtocol.Smart) { _logger.Info(_appSettings.GetProtocol() == VpnProtocol.Smart ? "Smart protocol is already enabled. Reconnection will fast forward to quick connect." : "Not asking again if the user wants to enable Smart Protocol. Reconnection will fast forward to quick connect."); return(VpnReconnectionSteps.QuickConnect); } if (_appSettings.IsSmartReconnectNotificationsEnabled()) { _notificationSender.Send( Translation.Get("Notifications_EnableSmartProtocol_ttl"), Translation.Get("Notifications_EnableSmartProtocol_msg")); } bool?isToChangeProtocolToAuto = _modals.Show <EnableSmartProtocolModalViewModel>(); if (isToChangeProtocolToAuto.HasValue && isToChangeProtocolToAuto.Value) { _appSettings.OvpnProtocol = "auto"; return(VpnReconnectionSteps.SimilarOnSmartProtocol); } _logger.Info("User refused to enable Smart Protocol. Reconnection will fast forward to quick connect."); return(VpnReconnectionSteps.QuickConnect); }
private void HandleNoServersAvailable(IReadOnlyCollection <Server> candidates, Profile profile) { if (profile.ProfileType == ProfileType.Custom) { HandleNoCustomServerAvailable(candidates.FirstOrDefault()); return; } if ((profile.Features.IsSecureCore() || profile.IsPredefined && _appSettings.SecureCore) && _userStorage.User().MaxTier < ServerTiers.Plus) { _modals.Show <ScUpsellModalViewModel>(); return; } if (!string.IsNullOrEmpty(profile.CountryCode)) { HandleNoCountryServersAvailable(candidates); return; } if (!candidates.Any()) { _dialogs.ShowWarning(StringResources.Get("Profiles_msg_NoServersAvailable")); return; } var userTierServers = candidates.UpToTierServers(_userStorage.User().MaxTier); if (!userTierServers.Any()) { if (candidates.BasicServers().Any()) { _modals.Show <UpsellModalViewModel>(); return; } if (candidates.PlusServers().Any()) { _modals.Show <PlusUpsellModalViewModel>(); return; } } if (!candidates.OnlineServers().Any()) { _dialogs.ShowWarning(StringResources.Get("Profiles_msg_AllServersOffline")); return; } _modals.Show <NoServerDueTierUpsellModalViewModel>(); }
private void ShowModal(VpnStateChangedEventArgs e) { dynamic options = new ExpandoObject(); options.NetworkBlocked = e.NetworkBlocked; options.Error = e.Error; _modals.Show <DisconnectErrorModalViewModel>(options); }
private async Task ValidateTime() { DateTime?networkTime = _ntpClient.GetNetworkUtcTime(); if (networkTime.HasValue && Math.Abs((networkTime.Value - DateTime.UtcNow).TotalSeconds) > TIME_LIMIT_IN_SECONDS) { _logger.Info("[SystemTimeValidator] incorrect system time detected."); _modals.Show <IncorrectSystemTimeModalViewModel>(); } }
private void OnActionableFailureResult(object sender, ActionableFailureApiResultEventArgs e) { string error = e.Result.Error; if (e.Result.StatusCode == HttpStatusCode.Unauthorized) { error = Translation.Get("Login_Error_msg_Unauthorized"); } _apiActionModalViewModel.SetView(error, e.Result.Actions); _modals.Show <ApiActionModalViewModel>(); }
public void RequestExit() { if (ShowModal()) { bool?result = _modals.Show <ExitModalViewModel>(); if (result == false) { return; } } PendingExit = true; _vpnService.UnRegisterCallback(); Application.Current.Shutdown(); }
private async Task InvokeAction(Func<Task> action) { try { await action(); } catch (EndpointNotFoundException) { var result = _modals.Show<ServiceStartModalViewModel>(); if (result != null && result.Value) { await action(); } } catch (Exception e) when (IsConnectionException(e)) { _logger.Error(e); } }
public void OnAppOutdated(object sender, BaseResponse e) { if (_notified) { return; } _notified = true; _scheduler.Schedule(() => { if (_vpnStatus != VpnStatus.Disconnected) { _vpnServiceManager.Disconnect(VpnError.Unknown); } _userAuth.Logout(); _loginWindow.Hide(); _modals.Show <OutdatedAppModalViewModel>(); }); }
private void ShowForwardedTrafficModal() { _modals.Show <P2PForwardModalViewModel>(); }
private void TroubleshootAction() { _modals.Show <TroubleshootModalViewModel>(); }
public bool?Verify(string token) { return(_modals.Show <HumanVerificationViewModel>(token)); }