Import Core framework into iOS target

This commit is contained in:
Davide De Rosa 2019-03-18 11:52:19 +01:00
parent f661008679
commit 5237aa3916
22 changed files with 55 additions and 17 deletions

View File

@ -25,6 +25,7 @@
import UIKit import UIKit
import TunnelKit import TunnelKit
import Passepartout_Core
@UIApplicationMain @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {

View File

@ -26,6 +26,7 @@
import Foundation import Foundation
import TunnelKit import TunnelKit
import MessageUI import MessageUI
import Passepartout_Core
class IssueReporter: NSObject { class IssueReporter: NSObject {
struct Attachments { struct Attachments {

View File

@ -27,6 +27,7 @@ import Foundation
import UIKit import UIKit
import TunnelKit import TunnelKit
import SwiftyBeaver import SwiftyBeaver
import Passepartout_Core
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self

View File

@ -25,6 +25,7 @@
import UIKit import UIKit
import TunnelKit import TunnelKit
import Passepartout_Core
extension UITableViewCell { extension UITableViewCell {
func applyChecked(_ checked: Bool, _ theme: Theme) { func applyChecked(_ checked: Bool, _ theme: Theme) {

View File

@ -25,6 +25,7 @@
import UIKit import UIKit
import MessageUI import MessageUI
import Passepartout_Core
extension UIColor { extension UIColor {
convenience init(rgb: UInt32, alpha: CGFloat) { convenience init(rgb: UInt32, alpha: CGFloat) {

View File

@ -26,6 +26,7 @@
import Foundation import Foundation
import Intents import Intents
import SwiftyBeaver import SwiftyBeaver
import Passepartout_Core
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
protocol AccountViewControllerDelegate: class { protocol AccountViewControllerDelegate: class {
func accountController(_: AccountViewController, didEnterCredentials credentials: Credentials) func accountController(_: AccountViewController, didEnterCredentials credentials: Credentials)

View File

@ -26,6 +26,7 @@
import UIKit import UIKit
import TunnelKit import TunnelKit
import SwiftyBeaver import SwiftyBeaver
import Passepartout_Core
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self

View File

@ -25,6 +25,7 @@
import UIKit import UIKit
import SwiftyBeaver import SwiftyBeaver
import Passepartout_Core
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self

View File

@ -25,6 +25,7 @@
import UIKit import UIKit
import TunnelKit import TunnelKit
import Passepartout_Core
protocol EndpointViewControllerDelegate: class { protocol EndpointViewControllerDelegate: class {
func endpointController(_: EndpointViewController, didUpdateWithNewAddress newAddress: String?, newProtocol: EndpointProtocol?) func endpointController(_: EndpointViewController, didUpdateWithNewAddress newAddress: String?, newProtocol: EndpointProtocol?)

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
class AboutViewController: UITableViewController, TableModelHost { class AboutViewController: UITableViewController, TableModelHost {

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
class CreditsViewController: UITableViewController, TableModelHost { class CreditsViewController: UITableViewController, TableModelHost {
private let licenses = AppConstants.License.all private let licenses = AppConstants.License.all

View File

@ -26,6 +26,7 @@
import UIKit import UIKit
import TunnelKit import TunnelKit
import SwiftyBeaver import SwiftyBeaver
import Passepartout_Core
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
class LabelViewController: UIViewController { class LabelViewController: UIViewController {
@IBOutlet private weak var scrollView: UIScrollView? @IBOutlet private weak var scrollView: UIScrollView?

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
// XXX: convoluted due to the separation of provider/host profiles // XXX: convoluted due to the separation of provider/host profiles

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
class VersionViewController: UIViewController { class VersionViewController: UIViewController {
@IBOutlet private weak var scrollView: UIScrollView? @IBOutlet private weak var scrollView: UIScrollView?

View File

@ -26,6 +26,7 @@
import UIKit import UIKit
import TunnelKit import TunnelKit
import SwiftyBeaver import SwiftyBeaver
import Passepartout_Core
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
class WizardProviderViewController: UITableViewController { class WizardProviderViewController: UITableViewController {
var availableNames: [Infrastructure.Name] = [] var availableNames: [Infrastructure.Name] = []

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
protocol ProviderPoolViewControllerDelegate: class { protocol ProviderPoolViewControllerDelegate: class {
func providerPoolController(_: ProviderPoolViewController, didSelectPool pool: Pool) func providerPoolController(_: ProviderPoolViewController, didSelectPool pool: Pool)

View File

@ -24,6 +24,7 @@
// //
import UIKit import UIKit
import Passepartout_Core
protocol ProviderPresetViewControllerDelegate: class { protocol ProviderPresetViewControllerDelegate: class {
func providerPresetController(_: ProviderPresetViewController, didSelectPreset preset: InfrastructurePreset) func providerPresetController(_: ProviderPresetViewController, didSelectPreset preset: InfrastructurePreset)

View File

@ -27,6 +27,7 @@ import UIKit
import NetworkExtension import NetworkExtension
import CoreTelephony import CoreTelephony
import TunnelKit import TunnelKit
import Passepartout_Core
class ServiceViewController: UIViewController, TableModelHost { class ServiceViewController: UIViewController, TableModelHost {
@IBOutlet private weak var tableView: UITableView! @IBOutlet private weak var tableView: UITableView!
@ -511,6 +512,19 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
return ip 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 { func numberOfSections(in tableView: UITableView) -> Int {
return model.count return model.count
} }
@ -938,7 +952,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
trustedNetworks.delegate = self trustedNetworks.delegate = self
trustedNetworks.load(from: service.preferences) trustedNetworks.load(from: service.preferences)
model.set(trustedNetworks.rows, in: .trusted) model.set(trustedNetworks.rows.map { mappedTrustedNetworksRow($0) }, in: .trusted)
} }
private func reloadVpnStatus() { private func reloadVpnStatus() {
@ -1005,7 +1019,7 @@ extension ServiceViewController: TrustedNetworksModelDelegate {
} }
func trustedNetworks(_: TrustedNetworksModel, shouldInsertWifiAt rowIndex: Int) { 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) tableView.insertRows(at: [IndexPath(row: rowIndex, section: trustedSectionIndex)], with: .bottom)
} }
@ -1021,7 +1035,7 @@ extension ServiceViewController: TrustedNetworksModelDelegate {
} }
func trustedNetworks(_: TrustedNetworksModel, shouldDeleteWifiAt rowIndex: Int) { 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) tableView.deleteRows(at: [IndexPath(row: rowIndex, section: trustedSectionIndex)], with: .top)
} }

View File

@ -40,6 +40,14 @@ public protocol TrustedNetworksModelDelegate: class {
} }
public class TrustedNetworksModel { public class TrustedNetworksModel {
public enum RowType {
case trustsMobile
case trustedWiFi
case addCurrentWiFi
}
public private(set) var trustedWifis: [String: Bool] public private(set) var trustedWifis: [String: Bool]
public private(set) var sortedWifis: [String] public private(set) var sortedWifis: [String]
@ -49,9 +57,7 @@ public class TrustedNetworksModel {
public private(set) var trustsMobileNetwork: Bool public private(set) var trustsMobileNetwork: Bool
// FIXME public private(set) var rows: [RowType]
// public private(set) var rows: [ServiceViewController.RowType]
public private(set) var rows: [Int]
#endif #endif
public weak var delegate: TrustedNetworksModelDelegate? public weak var delegate: TrustedNetworksModelDelegate?
@ -73,15 +79,14 @@ public class TrustedNetworksModel {
#if os(iOS) #if os(iOS)
trustsMobileNetwork = preferences.trustsMobileNetwork trustsMobileNetwork = preferences.trustsMobileNetwork
// FIXME rows.removeAll()
// rows.removeAll() if hasMobileNetwork {
// if hasMobileNetwork { rows.append(.trustsMobile)
// rows.append(.trustedMobile) }
// } for _ in sortedWifis {
// for _ in sortedWifis { rows.append(.trustedWiFi)
// rows.append(.trustedWiFi) }
// } rows.append(.addCurrentWiFi)
// rows.append(.trustedAddCurrentWiFi)
#endif #endif
} }
@ -139,8 +144,7 @@ public class TrustedNetworksModel {
if !isDuplicate { if !isDuplicate {
sortedWifis.insert(wifiToAdd, at: index) sortedWifis.insert(wifiToAdd, at: index)
#if os(iOS) #if os(iOS)
// FIXME rows.insert(.trustedWiFi, at: rowIndex)
// rows.insert(.trustedWiFi, at: rowIndex)
#endif #endif
delegate?.trustedNetworks(self, shouldInsertWifiAt: rowIndex) delegate?.trustedNetworks(self, shouldInsertWifiAt: rowIndex)
} else { } else {