macOS: Present tunnel activation errors from the window when possible
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
252d940d34
commit
df8b400850
|
@ -20,29 +20,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
self.statusItem = createStatusBarItem(with: statusMenu)
|
||||
|
||||
tunnelsManager.tunnelsListDelegate = statusMenu
|
||||
tunnelsManager.activationDelegate = self
|
||||
tunnelsManager.activationDelegate = statusMenu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AppDelegate: TunnelsManagerActivationDelegate {
|
||||
func tunnelActivationAttemptFailed(tunnel: TunnelContainer, error: TunnelsManagerActivationAttemptError) {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: nil)
|
||||
}
|
||||
|
||||
func tunnelActivationAttemptSucceeded(tunnel: TunnelContainer) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
func tunnelActivationFailed(tunnel: TunnelContainer, error: TunnelsManagerActivationError) {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: nil)
|
||||
}
|
||||
|
||||
func tunnelActivationSucceeded(tunnel: TunnelContainer) {
|
||||
// Nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
func createStatusBarItem(with statusMenu: StatusMenu) -> NSStatusItem {
|
||||
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
|
||||
if let statusBarImage = NSImage(named: "WireGuardMacStatusBarIcon") {
|
||||
|
|
|
@ -217,3 +217,29 @@ extension StatusMenu: TunnelsManagerListDelegate {
|
|||
manageTunnelsRootVC?.tunnelsListVC?.tunnelRemoved(at: index)
|
||||
}
|
||||
}
|
||||
|
||||
extension StatusMenu: TunnelsManagerActivationDelegate {
|
||||
func tunnelActivationAttemptFailed(tunnel: TunnelContainer, error: TunnelsManagerActivationAttemptError) {
|
||||
if let manageTunnelsRootVC = manageTunnelsRootVC, manageTunnelsWindow.isVisible {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: manageTunnelsRootVC)
|
||||
} else {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: nil)
|
||||
}
|
||||
}
|
||||
|
||||
func tunnelActivationAttemptSucceeded(tunnel: TunnelContainer) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
func tunnelActivationFailed(tunnel: TunnelContainer, error: TunnelsManagerActivationError) {
|
||||
if let manageTunnelsRootVC = manageTunnelsRootVC, manageTunnelsWindow.isVisible {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: manageTunnelsRootVC)
|
||||
} else {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: nil)
|
||||
}
|
||||
}
|
||||
|
||||
func tunnelActivationSucceeded(tunnel: TunnelContainer) {
|
||||
// Nothing to do
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue