From 9292919816976917e0a8a6e8763f417e5046a7d1 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 22 Oct 2018 10:04:58 +0200 Subject: [PATCH] Update VPN status after profile reinstall Should now cover all scenarios. --- Passepartout-iOS/Scenes/ServiceViewController.swift | 1 + Passepartout/Sources/VPN/StandardVPNProvider.swift | 8 +++++++- Passepartout/Sources/VPN/VPNProvider.swift | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 40bf56ae..d8e3a985 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -88,6 +88,7 @@ class ServiceViewController: UIViewController, TableModelHost { let nc = NotificationCenter.default nc.addObserver(self, selector: #selector(applicationDidBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil) nc.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidChangeStatus, object: nil) + nc.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidReinstall, object: nil) // run this no matter what // XXX: convenient here vs AppDelegate for updating table diff --git a/Passepartout/Sources/VPN/StandardVPNProvider.swift b/Passepartout/Sources/VPN/StandardVPNProvider.swift index 4fd0af85..579f1753 100644 --- a/Passepartout/Sources/VPN/StandardVPNProvider.swift +++ b/Passepartout/Sources/VPN/StandardVPNProvider.swift @@ -37,7 +37,9 @@ class StandardVPNProvider: VPNProvider { init(bundleIdentifier: String) { self.bundleIdentifier = bundleIdentifier - NotificationCenter.default.addObserver(self, selector: #selector(vpnDidUpdate(_:)), name: .NEVPNStatusDidChange, object: nil) + let nc = NotificationCenter.default + nc.addObserver(self, selector: #selector(vpnDidUpdate(_:)), name: .NEVPNStatusDidChange, object: nil) + nc.addObserver(self, selector: #selector(vpnDidReinstall(_:)), name: .NEVPNConfigurationChange, object: nil) } deinit { @@ -264,4 +266,8 @@ class StandardVPNProvider: VPNProvider { NotificationCenter.default.post(name: .VPNDidChangeStatus, object: self) } + + @objc private func vpnDidReinstall(_ notification: Notification) { + NotificationCenter.default.post(name: .VPNDidReinstall, object: self) + } } diff --git a/Passepartout/Sources/VPN/VPNProvider.swift b/Passepartout/Sources/VPN/VPNProvider.swift index 3502d258..9ccc2841 100644 --- a/Passepartout/Sources/VPN/VPNProvider.swift +++ b/Passepartout/Sources/VPN/VPNProvider.swift @@ -53,4 +53,6 @@ extension Notification.Name { static let VPNDidPrepare = Notification.Name("VPNDidPrepare") static let VPNDidChangeStatus = Notification.Name("VPNDidChangeStatus") + + static let VPNDidReinstall = Notification.Name("VPNDidReinstall") }