From 5237aa391620eee8d428a7afef041fb357e59908 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 18 Mar 2019 11:52:19 +0100 Subject: [PATCH] Import Core framework into iOS target --- Passepartout-iOS/AppDelegate.swift | 1 + Passepartout-iOS/Global/IssueReporter.swift | 1 + .../Global/ParsingResult+Alerts.swift | 1 + Passepartout-iOS/Global/Theme+Cells.swift | 1 + Passepartout-iOS/Global/Theme.swift | 1 + .../Intents/InteractionsHandler.swift | 1 + .../Scenes/AccountViewController.swift | 1 + .../Scenes/ConfigurationViewController.swift | 1 + .../Scenes/DebugLogViewController.swift | 1 + .../Scenes/EndpointViewController.swift | 1 + .../Organizer/AboutViewController.swift | 1 + .../Organizer/CreditsViewController.swift | 1 + .../ImportedHostsViewController.swift | 1 + .../Organizer/LabelViewController.swift | 1 + .../Organizer/OrganizerViewController.swift | 1 + .../Organizer/VersionViewController.swift | 1 + .../Organizer/WizardHostViewController.swift | 1 + .../WizardProviderViewController.swift | 1 + .../Scenes/ProviderPoolViewController.swift | 1 + .../Scenes/ProviderPresetViewController.swift | 1 + .../Scenes/ServiceViewController.swift | 20 ++++++++++-- .../Sources/Model/TrustedNetworks.swift | 32 +++++++++++-------- 22 files changed, 55 insertions(+), 17 deletions(-) diff --git a/Passepartout-iOS/AppDelegate.swift b/Passepartout-iOS/AppDelegate.swift index 6d428668..dcaaf4f3 100644 --- a/Passepartout-iOS/AppDelegate.swift +++ b/Passepartout-iOS/AppDelegate.swift @@ -25,6 +25,7 @@ import UIKit import TunnelKit +import Passepartout_Core @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { diff --git a/Passepartout-iOS/Global/IssueReporter.swift b/Passepartout-iOS/Global/IssueReporter.swift index 194bc8e6..dc437ed4 100644 --- a/Passepartout-iOS/Global/IssueReporter.swift +++ b/Passepartout-iOS/Global/IssueReporter.swift @@ -26,6 +26,7 @@ import Foundation import TunnelKit import MessageUI +import Passepartout_Core class IssueReporter: NSObject { struct Attachments { diff --git a/Passepartout-iOS/Global/ParsingResult+Alerts.swift b/Passepartout-iOS/Global/ParsingResult+Alerts.swift index f3f3fbb1..f1784b18 100644 --- a/Passepartout-iOS/Global/ParsingResult+Alerts.swift +++ b/Passepartout-iOS/Global/ParsingResult+Alerts.swift @@ -27,6 +27,7 @@ import Foundation import UIKit import TunnelKit import SwiftyBeaver +import Passepartout_Core private let log = SwiftyBeaver.self diff --git a/Passepartout-iOS/Global/Theme+Cells.swift b/Passepartout-iOS/Global/Theme+Cells.swift index 469c04f2..ac787c9c 100644 --- a/Passepartout-iOS/Global/Theme+Cells.swift +++ b/Passepartout-iOS/Global/Theme+Cells.swift @@ -25,6 +25,7 @@ import UIKit import TunnelKit +import Passepartout_Core extension UITableViewCell { func applyChecked(_ checked: Bool, _ theme: Theme) { diff --git a/Passepartout-iOS/Global/Theme.swift b/Passepartout-iOS/Global/Theme.swift index 22fcf133..de173668 100644 --- a/Passepartout-iOS/Global/Theme.swift +++ b/Passepartout-iOS/Global/Theme.swift @@ -25,6 +25,7 @@ import UIKit import MessageUI +import Passepartout_Core extension UIColor { convenience init(rgb: UInt32, alpha: CGFloat) { diff --git a/Passepartout-iOS/Intents/InteractionsHandler.swift b/Passepartout-iOS/Intents/InteractionsHandler.swift index a55d6e9a..b5dae4fb 100644 --- a/Passepartout-iOS/Intents/InteractionsHandler.swift +++ b/Passepartout-iOS/Intents/InteractionsHandler.swift @@ -26,6 +26,7 @@ import Foundation import Intents import SwiftyBeaver +import Passepartout_Core private let log = SwiftyBeaver.self diff --git a/Passepartout-iOS/Scenes/AccountViewController.swift b/Passepartout-iOS/Scenes/AccountViewController.swift index 426bb577..5f5f45b3 100644 --- a/Passepartout-iOS/Scenes/AccountViewController.swift +++ b/Passepartout-iOS/Scenes/AccountViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core protocol AccountViewControllerDelegate: class { func accountController(_: AccountViewController, didEnterCredentials credentials: Credentials) diff --git a/Passepartout-iOS/Scenes/ConfigurationViewController.swift b/Passepartout-iOS/Scenes/ConfigurationViewController.swift index 60c3f65f..2a7894dc 100644 --- a/Passepartout-iOS/Scenes/ConfigurationViewController.swift +++ b/Passepartout-iOS/Scenes/ConfigurationViewController.swift @@ -26,6 +26,7 @@ import UIKit import TunnelKit import SwiftyBeaver +import Passepartout_Core private let log = SwiftyBeaver.self diff --git a/Passepartout-iOS/Scenes/DebugLogViewController.swift b/Passepartout-iOS/Scenes/DebugLogViewController.swift index 46b06c00..0721c13a 100644 --- a/Passepartout-iOS/Scenes/DebugLogViewController.swift +++ b/Passepartout-iOS/Scenes/DebugLogViewController.swift @@ -25,6 +25,7 @@ import UIKit import SwiftyBeaver +import Passepartout_Core private let log = SwiftyBeaver.self diff --git a/Passepartout-iOS/Scenes/EndpointViewController.swift b/Passepartout-iOS/Scenes/EndpointViewController.swift index 3ecf4be8..32de79b7 100644 --- a/Passepartout-iOS/Scenes/EndpointViewController.swift +++ b/Passepartout-iOS/Scenes/EndpointViewController.swift @@ -25,6 +25,7 @@ import UIKit import TunnelKit +import Passepartout_Core protocol EndpointViewControllerDelegate: class { func endpointController(_: EndpointViewController, didUpdateWithNewAddress newAddress: String?, newProtocol: EndpointProtocol?) diff --git a/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift b/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift index b88e8e24..7985e0c9 100644 --- a/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core class AboutViewController: UITableViewController, TableModelHost { diff --git a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift index 16af484e..6de0b359 100644 --- a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core class CreditsViewController: UITableViewController, TableModelHost { private let licenses = AppConstants.License.all diff --git a/Passepartout-iOS/Scenes/Organizer/ImportedHostsViewController.swift b/Passepartout-iOS/Scenes/Organizer/ImportedHostsViewController.swift index b0b2eb4a..f02be685 100644 --- a/Passepartout-iOS/Scenes/Organizer/ImportedHostsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ImportedHostsViewController.swift @@ -26,6 +26,7 @@ import UIKit import TunnelKit import SwiftyBeaver +import Passepartout_Core private let log = SwiftyBeaver.self diff --git a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift index 64381751..8ab7930a 100644 --- a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core class LabelViewController: UIViewController { @IBOutlet private weak var scrollView: UIScrollView? diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 079a807e..621d10da 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core // XXX: convoluted due to the separation of provider/host profiles diff --git a/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift b/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift index 0a552cc7..06692ed5 100644 --- a/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core class VersionViewController: UIViewController { @IBOutlet private weak var scrollView: UIScrollView? diff --git a/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift b/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift index e0d92904..47fcae07 100644 --- a/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift @@ -26,6 +26,7 @@ import UIKit import TunnelKit import SwiftyBeaver +import Passepartout_Core private let log = SwiftyBeaver.self diff --git a/Passepartout-iOS/Scenes/Organizer/WizardProviderViewController.swift b/Passepartout-iOS/Scenes/Organizer/WizardProviderViewController.swift index de793957..537bee7c 100644 --- a/Passepartout-iOS/Scenes/Organizer/WizardProviderViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/WizardProviderViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core class WizardProviderViewController: UITableViewController { var availableNames: [Infrastructure.Name] = [] diff --git a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift index 07130173..066b9f1b 100644 --- a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift +++ b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core protocol ProviderPoolViewControllerDelegate: class { func providerPoolController(_: ProviderPoolViewController, didSelectPool pool: Pool) diff --git a/Passepartout-iOS/Scenes/ProviderPresetViewController.swift b/Passepartout-iOS/Scenes/ProviderPresetViewController.swift index 6a2e7176..fdeea113 100644 --- a/Passepartout-iOS/Scenes/ProviderPresetViewController.swift +++ b/Passepartout-iOS/Scenes/ProviderPresetViewController.swift @@ -24,6 +24,7 @@ // import UIKit +import Passepartout_Core protocol ProviderPresetViewControllerDelegate: class { func providerPresetController(_: ProviderPresetViewController, didSelectPreset preset: InfrastructurePreset) diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 1ad8b334..6483a641 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -27,6 +27,7 @@ import UIKit import NetworkExtension import CoreTelephony import TunnelKit +import Passepartout_Core class ServiceViewController: UIViewController, TableModelHost { @IBOutlet private weak var tableView: UITableView! @@ -511,6 +512,19 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog return ip } + private func mappedTrustedNetworksRow(_ from: TrustedNetworksModel.RowType) -> RowType { + switch from { + case .trustsMobile: + return .trustedMobile + + case .trustedWiFi: + return .trustedWiFi + + case .addCurrentWiFi: + return .trustedAddCurrentWiFi + } + } + func numberOfSections(in tableView: UITableView) -> Int { return model.count } @@ -938,7 +952,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog trustedNetworks.delegate = self trustedNetworks.load(from: service.preferences) - model.set(trustedNetworks.rows, in: .trusted) + model.set(trustedNetworks.rows.map { mappedTrustedNetworksRow($0) }, in: .trusted) } private func reloadVpnStatus() { @@ -1005,7 +1019,7 @@ extension ServiceViewController: TrustedNetworksModelDelegate { } func trustedNetworks(_: TrustedNetworksModel, shouldInsertWifiAt rowIndex: Int) { - model.set(trustedNetworks.rows, in: .trusted) + model.set(trustedNetworks.rows.map { mappedTrustedNetworksRow($0) }, in: .trusted) tableView.insertRows(at: [IndexPath(row: rowIndex, section: trustedSectionIndex)], with: .bottom) } @@ -1021,7 +1035,7 @@ extension ServiceViewController: TrustedNetworksModelDelegate { } func trustedNetworks(_: TrustedNetworksModel, shouldDeleteWifiAt rowIndex: Int) { - model.set(trustedNetworks.rows, in: .trusted) + model.set(trustedNetworks.rows.map { mappedTrustedNetworksRow($0) }, in: .trusted) tableView.deleteRows(at: [IndexPath(row: rowIndex, section: trustedSectionIndex)], with: .top) } diff --git a/Passepartout/Sources/Model/TrustedNetworks.swift b/Passepartout/Sources/Model/TrustedNetworks.swift index 3ea59ccb..baecf4e0 100644 --- a/Passepartout/Sources/Model/TrustedNetworks.swift +++ b/Passepartout/Sources/Model/TrustedNetworks.swift @@ -40,6 +40,14 @@ public protocol TrustedNetworksModelDelegate: class { } public class TrustedNetworksModel { + public enum RowType { + case trustsMobile + + case trustedWiFi + + case addCurrentWiFi + } + public private(set) var trustedWifis: [String: Bool] public private(set) var sortedWifis: [String] @@ -49,9 +57,7 @@ public class TrustedNetworksModel { public private(set) var trustsMobileNetwork: Bool - // FIXME -// public private(set) var rows: [ServiceViewController.RowType] - public private(set) var rows: [Int] + public private(set) var rows: [RowType] #endif public weak var delegate: TrustedNetworksModelDelegate? @@ -73,15 +79,14 @@ public class TrustedNetworksModel { #if os(iOS) trustsMobileNetwork = preferences.trustsMobileNetwork - // FIXME -// rows.removeAll() -// if hasMobileNetwork { -// rows.append(.trustedMobile) -// } -// for _ in sortedWifis { -// rows.append(.trustedWiFi) -// } -// rows.append(.trustedAddCurrentWiFi) + rows.removeAll() + if hasMobileNetwork { + rows.append(.trustsMobile) + } + for _ in sortedWifis { + rows.append(.trustedWiFi) + } + rows.append(.addCurrentWiFi) #endif } @@ -139,8 +144,7 @@ public class TrustedNetworksModel { if !isDuplicate { sortedWifis.insert(wifiToAdd, at: index) #if os(iOS) - // FIXME -// rows.insert(.trustedWiFi, at: rowIndex) + rows.insert(.trustedWiFi, at: rowIndex) #endif delegate?.trustedNetworks(self, shouldInsertWifiAt: rowIndex) } else {