private void RegisterEvents() { IVpnServiceManager vpnServiceManager = Resolve <IVpnServiceManager>(); UserAuth userAuth = Resolve <UserAuth>(); AppWindow appWindow = Resolve <AppWindow>(); IAppSettings appSettings = Resolve <IAppSettings>(); Resolve <ISettingsServiceClientManager>(); Resolve <IServerUpdater>().ServersUpdated += (sender, e) => { IEnumerable <IServersAware> instances = Resolve <IEnumerable <IServersAware> >(); foreach (IServersAware instance in instances) { instance.OnServersUpdated(); } }; Resolve <IUserLocationService>().UserLocationChanged += (sender, location) => { IEnumerable <IUserLocationAware> instances = Resolve <IEnumerable <IUserLocationAware> >(); foreach (IUserLocationAware instance in instances) { instance.OnUserLocationChanged(location); } }; Resolve <IAnnouncements>().AnnouncementsChanged += (sender, e) => { IEnumerable <IAnnouncementsAware> instances = Resolve <IEnumerable <IAnnouncementsAware> >(); foreach (IAnnouncementsAware instance in instances) { instance.OnAnnouncementsChanged(); } }; userAuth.UserLoggingIn += (sender, e) => OnUserLoggingIn(); userAuth.UserLoggedIn += async(sender, e) => { GuestHoleState guestHoleState = Resolve <GuestHoleState>(); await Resolve <IServerUpdater>().Update(); if (guestHoleState.Active) { await Resolve <IVpnServiceManager>().Disconnect(VpnError.NoneKeepEnabledKillSwitch); guestHoleState.SetState(false); } IEnumerable <ILoggedInAware> instances = Resolve <IEnumerable <ILoggedInAware> >(); foreach (ILoggedInAware instance in instances) { instance.OnUserLoggedIn(); } await SwitchToAppWindow(e.AutoLogin); }; userAuth.UserLoggedOut += (sender, e) => { Resolve <IModals>().CloseAll(); SwitchToLoginWindow(); Resolve <AppWindow>().Hide(); IEnumerable <ILogoutAware> instances = Resolve <IEnumerable <ILogoutAware> >(); foreach (ILogoutAware instance in instances) { instance.OnUserLoggedOut(); } }; Resolve <IUserStorage>().UserDataChanged += (sender, e) => { IEnumerable <IUserDataAware> instances = Resolve <IEnumerable <IUserDataAware> >(); foreach (IUserDataAware instance in instances) { instance.OnUserDataChanged(); } }; Resolve <IUserStorage>().VpnPlanChanged += async(sender, e) => { IEnumerable <IVpnPlanAware> instances = Resolve <IEnumerable <IVpnPlanAware> >(); foreach (IVpnPlanAware instance in instances) { await instance.OnVpnPlanChangedAsync(e); } }; Resolve <SyncProfiles>().SyncStatusChanged += (sender, e) => { IEnumerable <IProfileSyncStatusAware> instances = Resolve <IEnumerable <IProfileSyncStatusAware> >(); foreach (IProfileSyncStatusAware instance in instances) { instance.OnProfileSyncStatusChanged(e.Status, e.ErrorMessage, e.ChangesSyncedAt); } }; Resolve <PinFactory>().PinsChanged += (sender, e) => { IEnumerable <IPinChangeAware> instances = Resolve <IEnumerable <IPinChangeAware> >(); foreach (IPinChangeAware instance in instances) { instance.OnPinsChanged(); } }; vpnServiceManager.RegisterCallback(async(e) => { Resolve <IVpnManager>().OnVpnStateChanged(e); await Resolve <LoginViewModel>().OnVpnStateChanged(e); await Resolve <GuestHoleConnector>().OnVpnStateChanged(e); }); Resolve <IVpnManager>().VpnStateChanged += (sender, e) => { IEnumerable <IVpnStateAware> instances = Resolve <IEnumerable <IVpnStateAware> >(); foreach (IVpnStateAware instance in instances) { instance.OnVpnStateChanged(e); } Resolve <IEventAggregator>().PublishOnCurrentThread(e); }; Resolve <UpdateService>().UpdateStateChanged += (sender, e) => { IEnumerable <IUpdateStateAware> instances = Resolve <IEnumerable <IUpdateStateAware> >(); foreach (IUpdateStateAware instance in instances) { instance.OnUpdateStateChanged(e); } }; Resolve <P2PDetector>().TrafficForwarded += (sender, ip) => { IEnumerable <ITrafficForwardedAware> instances = Resolve <IEnumerable <ITrafficForwardedAware> >(); foreach (ITrafficForwardedAware instance in instances) { instance.OnTrafficForwarded(ip); } }; Resolve <SidebarManager>().ManualSidebarModeChangeRequested += appWindow.OnManualSidebarModeChangeRequested; appSettings.PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(IAppSettings.Language)) { TranslationSource.Instance.CurrentCulture = new CultureInfo(appSettings.Language); } IEnumerable <ISettingsAware> instances = Resolve <IEnumerable <ISettingsAware> >(); foreach (ISettingsAware instance in instances) { instance.OnAppSettingsChanged(e); } }; Resolve <Onboarding.Onboarding>().StepChanged += (sender, e) => { IEnumerable <IOnboardingStepAware> instances = Resolve <IEnumerable <IOnboardingStepAware> >(); foreach (IOnboardingStepAware instance in instances) { instance.OnStepChanged(e); } }; Resolve <TrialTimer>().TrialTimerTicked += (sender, e) => { IEnumerable <ITrialDurationAware> instances = Resolve <IEnumerable <ITrialDurationAware> >(); foreach (ITrialDurationAware instance in instances) { instance.OnTrialSecondElapsed(e); } }; Resolve <Trial.Trial>().StateChanged += async(sender, e) => { IEnumerable <ITrialStateAware> instances = Resolve <IEnumerable <ITrialStateAware> >(); foreach (ITrialStateAware instance in instances) { await instance.OnTrialStateChangedAsync(e); } }; Resolve <GuestHoleState>().GuestHoleStateChanged += (sender, active) => { IEnumerable <IGuestHoleStateAware> instances = Resolve <IEnumerable <IGuestHoleStateAware> >(); foreach (IGuestHoleStateAware instance in instances) { instance.OnGuestHoleStateChanged(active); } }; Resolve <EventClient>().ApiDataChanged += async(sender, e) => { IEnumerable <IApiDataChangeAware> instances = Resolve <IEnumerable <IApiDataChangeAware> >(); foreach (IApiDataChangeAware instance in instances) { await instance.OnApiDataChanged(e); } }; Resolve <UnauthorizedResponseHandler>().SessionExpired += (sender, e) => { Resolve <ExpiredSessionHandler>().Execute(); }; Resolve <OutdatedAppHandler>().AppOutdated += Resolve <OutdatedAppNotification>().OnAppOutdated; Resolve <IModals>(); Resolve <InsecureNetworkNotification>(); }
public void RegisterCallback(Action<VpnStateChangedEventArgs> onVpnStateChanged) { _decorated.RegisterCallback(onVpnStateChanged); }