aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-02-15 01:06:44 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-15 01:14:14 +0100
commitfcca2d4fec803e40c999c3dcb4d2925ebf59c01a (patch)
treeca4898832961fc3994f71ac615422d2acde51760 /WireGuard/WireGuard/UI/macOS
parentVersion bump (diff)
downloadwireguard-apple-fcca2d4fec803e40c999c3dcb4d2925ebf59c01a.tar.xz
wireguard-apple-fcca2d4fec803e40c999c3dcb4d2925ebf59c01a.zip
macOS: Show privacy notice on adding first tunnel0.0.20190207-3
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 <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS')
-rw-r--r--WireGuard/WireGuard/UI/macOS/AppStorePrivacyNotice.swift29
-rw-r--r--WireGuard/WireGuard/UI/macOS/ImportPanelPresenter.swift4
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift16
3 files changed, 41 insertions, 8 deletions
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)
}
}
}