From fcca2d4fec803e40c999c3dcb4d2925ebf59c01a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 15 Feb 2019 01:06:44 +0100 Subject: macOS: Show privacy notice on adding first tunnel App store reviewers don't understand that this isn't a service. Revert this as soon as they come to their senses. Signed-off-by: Jason A. Donenfeld --- .../WireGuard/UI/macOS/AppStorePrivacyNotice.swift | 29 ++++++++++++++++++++++ .../WireGuard/UI/macOS/ImportPanelPresenter.swift | 4 ++- .../ViewController/TunnelEditViewController.swift | 16 ++++++------ 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 WireGuard/WireGuard/UI/macOS/AppStorePrivacyNotice.swift (limited to 'WireGuard/WireGuard/UI') diff --git a/WireGuard/WireGuard/UI/macOS/AppStorePrivacyNotice.swift b/WireGuard/WireGuard/UI/macOS/AppStorePrivacyNotice.swift new file mode 100644 index 0000000..15aeb8d --- /dev/null +++ b/WireGuard/WireGuard/UI/macOS/AppStorePrivacyNotice.swift @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved. + +import Cocoa + +class AppStorePrivacyNotice { + // The App Store Review Board does not comprehend the fact that this application + // is not a service and does not have any servers of its own. They therefore require + // us to give a notice regarding collection of user data using our non-existent + // servers. This demand is obviously impossible to fulfill, since it doesn't make sense, + // but we do our best here to show something in that category. + static func show(from sourceVC: NSViewController?, into tunnelsManager: TunnelsManager, _ callback: @escaping () -> Void) { + if tunnelsManager.numberOfTunnels() > 0 { + callback() + return + } + let alert = NSAlert() + + alert.messageText = tr("macPrivacyNoticeMessage") + alert.informativeText = tr("macPrivacyNoticeInfo") + alert.alertStyle = NSAlert.Style.warning + if let window = sourceVC?.view.window { + alert.beginSheetModal(for: window) { _ in callback() } + } else { + alert.runModal() + callback() + } + } +} diff --git a/WireGuard/WireGuard/UI/macOS/ImportPanelPresenter.swift b/WireGuard/WireGuard/UI/macOS/ImportPanelPresenter.swift index 3281142..1ef8f75 100644 --- a/WireGuard/WireGuard/UI/macOS/ImportPanelPresenter.swift +++ b/WireGuard/WireGuard/UI/macOS/ImportPanelPresenter.swift @@ -13,7 +13,9 @@ class ImportPanelPresenter { guard let tunnelsManager = tunnelsManager else { return } guard response == .OK else { return } guard let url = openPanel.url else { return } - TunnelImporter.importFromFile(url: url, into: tunnelsManager, sourceVC: sourceVC, errorPresenterType: ErrorPresenter.self) + AppStorePrivacyNotice.show(from: sourceVC, into: tunnelsManager) { + TunnelImporter.importFromFile(url: url, into: tunnelsManager, sourceVC: sourceVC, errorPresenterType: ErrorPresenter.self) + } } } } diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift index 395eeb4..efb3fd7 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift @@ -219,14 +219,16 @@ class TunnelEditViewController: NSViewController { } } else { // We're creating a new tunnel - tunnelsManager.add(tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] result in - if let error = result.error { - ErrorPresenter.showErrorAlert(error: error, from: self) - return + AppStorePrivacyNotice.show(from: self, into: tunnelsManager) { [weak self] in + self?.tunnelsManager.add(tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] result in + if let error = result.error { + ErrorPresenter.showErrorAlert(error: error, from: self) + return + } + let tunnel: TunnelContainer = result.value! + self?.dismiss(self) + self?.delegate?.tunnelSaved(tunnel: tunnel) } - let tunnel: TunnelContainer = result.value! - self?.dismiss(self) - self?.delegate?.tunnelSaved(tunnel: tunnel) } } } -- cgit v1.2.3-59-g8ed1b