diff --git a/Wireguard/Models/Profile+CoreDataClass.swift b/WireGuard/Models/Tunnel+CoreDataClass.swift similarity index 65% rename from Wireguard/Models/Profile+CoreDataClass.swift rename to WireGuard/Models/Tunnel+CoreDataClass.swift index 073be66..16a47ef 100644 --- a/Wireguard/Models/Profile+CoreDataClass.swift +++ b/WireGuard/Models/Tunnel+CoreDataClass.swift @@ -1,5 +1,5 @@ // -// Profile+CoreDataClass.swift +// Tunnel+CoreDataClass.swift // WireGuard // // Created by Jeroen Leenarts on 23-05-18. @@ -10,7 +10,7 @@ import Foundation import CoreData -@objc(Profile) -public class Profile: NSManagedObject { +@objc(Tunnel) +public class Tunnel: NSManagedObject { } diff --git a/Wireguard/Models/Profile+CoreDataProperties.swift b/WireGuard/Models/Tunnel+CoreDataProperties.swift similarity index 83% rename from Wireguard/Models/Profile+CoreDataProperties.swift rename to WireGuard/Models/Tunnel+CoreDataProperties.swift index 369d87c..2c7c741 100644 --- a/Wireguard/Models/Profile+CoreDataProperties.swift +++ b/WireGuard/Models/Tunnel+CoreDataProperties.swift @@ -1,5 +1,5 @@ // -// Profile+CoreDataProperties.swift +// Tunnel+CoreDataProperties.swift // WireGuard // // Created by Jeroen Leenarts on 23-05-18. @@ -10,10 +10,10 @@ import Foundation import CoreData -extension Profile { +extension Tunnel { - @nonobjc public class func fetchRequest() -> NSFetchRequest { - return NSFetchRequest(entityName: "Profile") + @nonobjc public class func fetchRequest() -> NSFetchRequest { + return NSFetchRequest(entityName: "Tunnel") } @NSManaged public var title: String? @@ -23,7 +23,7 @@ extension Profile { } // MARK: Generated accessors for peers -extension Profile { +extension Tunnel { @objc(addPeersObject:) @NSManaged public func addToPeers(_ value: Peer) diff --git a/WireGuard/ViewControllers/ProfileConfigurationTableViewController.swift b/WireGuard/ViewControllers/TunnelConfigurationTableViewController.swift similarity index 77% rename from WireGuard/ViewControllers/ProfileConfigurationTableViewController.swift rename to WireGuard/ViewControllers/TunnelConfigurationTableViewController.swift index 39290d4..ef93536 100644 --- a/WireGuard/ViewControllers/ProfileConfigurationTableViewController.swift +++ b/WireGuard/ViewControllers/TunnelConfigurationTableViewController.swift @@ -1,5 +1,5 @@ // -// ProfileConfigurationTableViewController.swift +// TunnelConfigurationTableViewController.swift // WireGuard // // Created by Jeroen Leenarts on 24-05-18. @@ -10,12 +10,12 @@ import UIKit import CoreData import BNRCoreDataStack -protocol ProfileConfigurationTableViewControllerDelegate: class { +protocol TunnelConfigurationTableViewControllerDelegate: class { } -class ProfileConfigurationTableViewController: UITableViewController { +class TunnelConfigurationTableViewController: UITableViewController { var viewContext: NSManagedObjectContext! - weak var delegate: ProfileConfigurationTableViewControllerDelegate? + weak var delegate: TunnelConfigurationTableViewControllerDelegate? override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 3 @@ -45,7 +45,7 @@ class AddPeerTableViewCell: UITableViewCell { } -extension ProfileConfigurationTableViewController: Identifyable {} +extension TunnelConfigurationTableViewController: Identifyable {} extension InterfaceTableViewCell: Identifyable {} extension PeerTableViewCell: Identifyable {} extension AddPeerTableViewCell: Identifyable {} diff --git a/Wireguard/ViewControllers/ConnectionsTableViewController.swift b/WireGuard/ViewControllers/TunnelsTableViewController.swift similarity index 66% rename from Wireguard/ViewControllers/ConnectionsTableViewController.swift rename to WireGuard/ViewControllers/TunnelsTableViewController.swift index 931945d..d769f89 100644 --- a/Wireguard/ViewControllers/ConnectionsTableViewController.swift +++ b/WireGuard/ViewControllers/TunnelsTableViewController.swift @@ -1,5 +1,5 @@ // -// ConnectionsTableViewController.swift +// TunnelsTableViewController.swift // WireGuard // // Created by Jeroen Leenarts on 23-05-18. @@ -11,30 +11,30 @@ import UIKit import CoreData import BNRCoreDataStack -protocol ConnectionsTableViewControllerDelegate: class { - func addProvider(connectionsTableViewController: ConnectionsTableViewController) - func connect(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) - func configure(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) - func delete(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) +protocol TunnelsTableViewControllerDelegate: class { + func addProvider(tunnelsTableViewController: TunnelsTableViewController) + func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) + func configure(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) + func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) } -class ConnectionsTableViewController: UITableViewController { - weak var delegate: ConnectionsTableViewControllerDelegate? +class TunnelsTableViewController: UITableViewController { + weak var delegate: TunnelsTableViewControllerDelegate? var viewContext: NSManagedObjectContext! - private lazy var fetchedResultsController: FetchedResultsController = { - let fetchRequest = NSFetchRequest() - fetchRequest.entity = Profile.entity() + private lazy var fetchedResultsController: FetchedResultsController = { + let fetchRequest = NSFetchRequest() + fetchRequest.entity = Tunnel.entity() fetchRequest.sortDescriptors = [NSSortDescriptor(key: "title", ascending: true)] - let frc = FetchedResultsController(fetchRequest: fetchRequest, + let frc = FetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: viewContext) frc.setDelegate(self.frcDelegate) return frc }() - private lazy var frcDelegate: ProfileFetchedResultsControllerDelegate = { // swiftlint:disable:this weak_delegate - return ProfileFetchedResultsControllerDelegate(tableView: self.tableView) + private lazy var frcDelegate: TunnelFetchedResultsControllerDelegate = { // swiftlint:disable:this weak_delegate + return TunnelFetchedResultsControllerDelegate(tableView: self.tableView) }() override func viewDidLoad() { @@ -47,7 +47,7 @@ class ConnectionsTableViewController: UITableViewController { } @IBAction func addProvider(_ sender: Any) { - delegate?.addProvider(connectionsTableViewController: self) + delegate?.addProvider(tunnelsTableViewController: self) } override func numberOfSections(in tableView: UITableView) -> Int { @@ -59,16 +59,16 @@ class ConnectionsTableViewController: UITableViewController { } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(type: ProfileTableViewCell.self, for: indexPath) + let cell = tableView.dequeueReusableCell(type: TunnelTableViewCell.self, for: indexPath) guard let sections = fetchedResultsController.sections else { fatalError("FetchedResultsController \(fetchedResultsController) should have sections, but found nil") } let section = sections[indexPath.section] - let profile = section.objects[indexPath.row] + let tunnel = section.objects[indexPath.row] - cell.textLabel?.text = profile.title + cell.textLabel?.text = tunnel.title return cell } @@ -79,9 +79,9 @@ class ConnectionsTableViewController: UITableViewController { } let section = sections[indexPath.section] - let profile = section.objects[indexPath.row] + let tunnel = section.objects[indexPath.row] - delegate?.connect(profile: profile, connectionsTableViewController: self) + delegate?.connect(tunnel: tunnel, tunnelsTableViewController: self) tableView.deselectRow(at: indexPath, animated: true) } @@ -92,9 +92,9 @@ class ConnectionsTableViewController: UITableViewController { } let section = sections[indexPath.section] - let profile = section.objects[indexPath.row] + let tunnel = section.objects[indexPath.row] - delegate?.configure(profile: profile, connectionsTableViewController: self) + delegate?.configure(tunnel: tunnel, tunnelsTableViewController: self) } @@ -110,16 +110,16 @@ class ConnectionsTableViewController: UITableViewController { } let section = sections[indexPath.section] - let profile = section.objects[indexPath.row] + let tunnel = section.objects[indexPath.row] - delegate?.delete(profile: profile, connectionsTableViewController: self) + delegate?.delete(tunnel: tunnel, tunnelsTableViewController: self) } } } -extension ConnectionsTableViewController: Identifyable {} +extension TunnelsTableViewController: Identifyable {} -class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControllerDelegate { +class TunnelFetchedResultsControllerDelegate: NSObject, FetchedResultsControllerDelegate { private weak var tableView: UITableView? @@ -128,19 +128,19 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle self.tableView = tableView } - func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController) { + func fetchedResultsControllerDidPerformFetch(_ controller: FetchedResultsController) { tableView?.reloadData() } - func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController) { + func fetchedResultsControllerWillChangeContent(_ controller: FetchedResultsController) { tableView?.beginUpdates() } - func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController) { + func fetchedResultsControllerDidChangeContent(_ controller: FetchedResultsController) { tableView?.endUpdates() } - func fetchedResultsController(_ controller: FetchedResultsController, didChangeObject change: FetchedResultsObjectChange) { + func fetchedResultsController(_ controller: FetchedResultsController, didChangeObject change: FetchedResultsObjectChange) { guard let tableView = tableView else { return } switch change { case let .insert(_, indexPath): @@ -157,7 +157,7 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle } } - func fetchedResultsController(_ controller: FetchedResultsController, didChangeSection change: FetchedResultsSectionChange) { + func fetchedResultsController(_ controller: FetchedResultsController, didChangeSection change: FetchedResultsSectionChange) { guard let tableView = tableView else { return } switch change { case let .insert(_, index): @@ -169,8 +169,8 @@ class ProfileFetchedResultsControllerDelegate: NSObject, FetchedResultsControlle } } -class ProfileTableViewCell: UITableViewCell { +class TunnelTableViewCell: UITableViewCell { } -extension ProfileTableViewCell: Identifyable {} +extension TunnelTableViewCell: Identifyable {} diff --git a/Wireguard.xcodeproj/project.pbxproj b/Wireguard.xcodeproj/project.pbxproj index 6b0a645..f814b8a 100644 --- a/Wireguard.xcodeproj/project.pbxproj +++ b/Wireguard.xcodeproj/project.pbxproj @@ -8,9 +8,9 @@ /* Begin PBXBuildFile section */ 48CF751B34E9703133F1B1AF /* Pods_WireGuard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 861983CAE8FDC13BC83E7E04 /* Pods_WireGuard.framework */; }; - 4A4BA6D820B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BA6D720B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift */; }; + 4A4BA6D820B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */; }; 4A4BACE620B5F1BF00F12B28 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BACE520B5F1BF00F12B28 /* AppDelegate.swift */; }; - 4A4BACE820B5F1BF00F12B28 /* ConnectionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BACE720B5F1BF00F12B28 /* ConnectionsTableViewController.swift */; }; + 4A4BACE820B5F1BF00F12B28 /* TunnelsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BACE720B5F1BF00F12B28 /* TunnelsTableViewController.swift */; }; 4A4BACEB20B5F1BF00F12B28 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACE920B5F1BF00F12B28 /* Main.storyboard */; }; 4A4BACED20B5F1C100F12B28 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACEC20B5F1C100F12B28 /* Assets.xcassets */; }; 4A4BACF020B5F1C100F12B28 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4BACEE20B5F1C100F12B28 /* LaunchScreen.storyboard */; }; @@ -21,8 +21,8 @@ 4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD0F20B5F6EC00F12B28 /* RootCoordinator.swift */; }; 4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */; }; 4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */; }; - 4A4BAD1A20B5F8FF00F12B28 /* Profile+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */; }; - 4A4BAD1B20B5F8FF00F12B28 /* Profile+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */; }; + 4A4BAD1A20B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */; }; + 4A4BAD1B20B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1920B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift */; }; 4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */; }; 4A4BAD2120B6026900F12B28 /* Peer+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1D20B6026900F12B28 /* Peer+CoreDataClass.swift */; }; 4A4BAD2220B6026900F12B28 /* Interface+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */; }; @@ -45,10 +45,10 @@ /* Begin PBXFileReference section */ 0CE52E030FAA93F3BF5747B2 /* Pods-WireGuard.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.release.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.release.xcconfig"; sourceTree = ""; }; 25E2BE31A33C8CCE6E79B6EF /* Pods-WireGuard.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WireGuard.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WireGuard/Pods-WireGuard.debug.xcconfig"; sourceTree = ""; }; - 4A4BA6D720B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileConfigurationTableViewController.swift; sourceTree = ""; }; + 4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelConfigurationTableViewController.swift; sourceTree = ""; }; 4A4BACE220B5F1BF00F12B28 /* WireGuard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WireGuard.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4A4BACE520B5F1BF00F12B28 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 4A4BACE720B5F1BF00F12B28 /* ConnectionsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionsTableViewController.swift; sourceTree = ""; }; + 4A4BACE720B5F1BF00F12B28 /* TunnelsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelsTableViewController.swift; sourceTree = ""; }; 4A4BACEA20B5F1BF00F12B28 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 4A4BACEC20B5F1C100F12B28 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4A4BACEF20B5F1C100F12B28 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -62,8 +62,8 @@ 4A4BAD0F20B5F6EC00F12B28 /* RootCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootCoordinator.swift; sourceTree = ""; }; 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Identifyable.swift; sourceTree = ""; }; 4A4BAD1620B5F8DE00F12B28 /* WireGuard.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WireGuard.xcdatamodel; sourceTree = ""; }; - 4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Profile+CoreDataClass.swift"; sourceTree = ""; }; - 4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Profile+CoreDataProperties.swift"; sourceTree = ""; }; + 4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Tunnel+CoreDataClass.swift"; sourceTree = ""; }; + 4A4BAD1920B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Tunnel+CoreDataProperties.swift"; sourceTree = ""; }; 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Peer+CoreDataProperties.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Peer+CoreDataProperties.swift"; sourceTree = ""; }; 4A4BAD1D20B6026900F12B28 /* Peer+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Peer+CoreDataClass.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Peer+CoreDataClass.swift"; sourceTree = ""; }; 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Interface+CoreDataProperties.swift"; path = "/Users/jeroenleenarts/code/wireguard-ios/Wireguard/Models/Interface+CoreDataProperties.swift"; sourceTree = ""; }; @@ -164,8 +164,8 @@ children = ( 4A4BAD1220B5F82400F12B28 /* Identifyable.swift */, 4A8AABD720B6A79100B6D8C1 /* UITableView+WireGuard.swift */, - 4A4BACE720B5F1BF00F12B28 /* ConnectionsTableViewController.swift */, - 4A4BA6D720B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift */, + 4A4BACE720B5F1BF00F12B28 /* TunnelsTableViewController.swift */, + 4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */, ); path = ViewControllers; sourceTree = ""; @@ -179,8 +179,8 @@ 4A4BAD1C20B6026900F12B28 /* Peer+CoreDataProperties.swift */, 4A4BAD1F20B6026900F12B28 /* Interface+CoreDataClass.swift */, 4A4BAD1E20B6026900F12B28 /* Interface+CoreDataProperties.swift */, - 4A4BAD1820B5F8FF00F12B28 /* Profile+CoreDataClass.swift */, - 4A4BAD1920B5F8FF00F12B28 /* Profile+CoreDataProperties.swift */, + 4A4BAD1820B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift */, + 4A4BAD1920B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift */, 4A4BAD1520B5F8DE00F12B28 /* WireGuard.xcdatamodeld */, ); path = Models; @@ -400,17 +400,17 @@ 4A7F6EDE20B674CD00B260B7 /* Address+CoreDataProperties.swift in Sources */, 4A4BAD1320B5F82400F12B28 /* Identifyable.swift in Sources */, 4A4BAD1720B5F8DE00F12B28 /* WireGuard.xcdatamodeld in Sources */, - 4A4BAD1A20B5F8FF00F12B28 /* Profile+CoreDataClass.swift in Sources */, - 4A4BACE820B5F1BF00F12B28 /* ConnectionsTableViewController.swift in Sources */, + 4A4BAD1A20B5F8FF00F12B28 /* Tunnel+CoreDataClass.swift in Sources */, + 4A4BACE820B5F1BF00F12B28 /* TunnelsTableViewController.swift in Sources */, 4A4BAD1020B5F6EC00F12B28 /* RootCoordinator.swift in Sources */, 4A4BAD0E20B5F6C300F12B28 /* Coordinator.swift in Sources */, - 4A4BA6D820B73CBA00223AB8 /* ProfileConfigurationTableViewController.swift in Sources */, + 4A4BA6D820B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift in Sources */, 4A4BAD2020B6026900F12B28 /* Peer+CoreDataProperties.swift in Sources */, 4A4BAD2320B6026900F12B28 /* Interface+CoreDataClass.swift in Sources */, 4A7F6EDD20B674CD00B260B7 /* Address+CoreDataClass.swift in Sources */, 4A8AABD820B6A79100B6D8C1 /* UITableView+WireGuard.swift in Sources */, 4A4BAD2120B6026900F12B28 /* Peer+CoreDataClass.swift in Sources */, - 4A4BAD1B20B5F8FF00F12B28 /* Profile+CoreDataProperties.swift in Sources */, + 4A4BAD1B20B5F8FF00F12B28 /* Tunnel+CoreDataProperties.swift in Sources */, 4A4BACE620B5F1BF00F12B28 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Wireguard/Base.lproj/Main.storyboard b/Wireguard/Base.lproj/Main.storyboard index b7bad2e..301c663 100644 --- a/Wireguard/Base.lproj/Main.storyboard +++ b/Wireguard/Base.lproj/Main.storyboard @@ -11,19 +11,32 @@ - + + + + + + + + + + + + + + - + - + - + @@ -43,7 +56,7 @@ - + @@ -56,10 +69,10 @@ - + - + @@ -235,15 +248,15 @@ - - + + - + @@ -256,7 +269,7 @@ - + @@ -393,7 +406,7 @@ - + diff --git a/Wireguard/Coordinators/AppCoordinator.swift b/Wireguard/Coordinators/AppCoordinator.swift index 477911d..1bc9ee6 100644 --- a/Wireguard/Coordinators/AppCoordinator.swift +++ b/Wireguard/Coordinators/AppCoordinator.swift @@ -11,6 +11,8 @@ import Foundation import CoreData import BNRCoreDataStack +extension UINavigationController: Identifyable {} + class AppCoordinator: RootViewCoordinator { let persistentContainer = NSPersistentContainer(name: "WireGuard") @@ -21,16 +23,16 @@ class AppCoordinator: RootViewCoordinator { var childCoordinators: [Coordinator] = [] var rootViewController: UIViewController { - return self.connectionsTableViewController + return self.tunnelsTableViewController } - var connectionsTableViewController: ConnectionsTableViewController! + var tunnelsTableViewController: TunnelsTableViewController! /// Window to manage let window: UIWindow let navigationController: UINavigationController = { - let navController = UINavigationController() + let navController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(type: UINavigationController.self) return navController }() @@ -54,14 +56,14 @@ class AppCoordinator: RootViewCoordinator { } else { DispatchQueue.main.async { //start - if let connectionsTableViewController = self?.storyboard.instantiateViewController(type: ConnectionsTableViewController.self) { - self?.connectionsTableViewController = connectionsTableViewController - self?.connectionsTableViewController.viewContext = self?.persistentContainer.viewContext - self?.connectionsTableViewController.delegate = self - self?.navigationController.viewControllers = [connectionsTableViewController] + if let tunnelsTableViewController = self?.storyboard.instantiateViewController(type: TunnelsTableViewController.self) { + self?.tunnelsTableViewController = tunnelsTableViewController + self?.tunnelsTableViewController.viewContext = self?.persistentContainer.viewContext + self?.tunnelsTableViewController.delegate = self + self?.navigationController.viewControllers = [tunnelsTableViewController] do { - if let context = self?.persistentContainer.viewContext, try Profile.countInContext(context) == 0 { - print("No profiles ... yet") + if let context = self?.persistentContainer.viewContext, try Tunnel.countInContext(context) == 0 { + print("No tunnels ... yet") } } catch { self?.showError(error) @@ -83,45 +85,45 @@ class AppCoordinator: RootViewCoordinator { } } -extension AppCoordinator: ConnectionsTableViewControllerDelegate { - func addProvider(connectionsTableViewController: ConnectionsTableViewController) { +extension AppCoordinator: TunnelsTableViewControllerDelegate { + func addProvider(tunnelsTableViewController: TunnelsTableViewController) { let addContext = persistentContainer.newBackgroundContext() - showProfileConfigurationViewController(profile: nil, context: addContext) + showTunnelConfigurationViewController(tunnel: nil, context: addContext) } - func connect(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { + func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) { // TODO implement - print("connect profile \(profile)") + print("connect tunnel \(tunnel)") } - func configure(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { + func configure(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) { // TODO implement - print("configure profile \(profile)") + print("configure tunnel \(tunnel)") let editContext = persistentContainer.newBackgroundContext() - var backgroundProfile: Profile? + var backgroundTunnel: Tunnel? editContext.performAndWait { - backgroundProfile = editContext.object(with: profile.objectID) as? Profile + backgroundTunnel = editContext.object(with: tunnel.objectID) as? Tunnel } - showProfileConfigurationViewController(profile: backgroundProfile, context: editContext) + showTunnelConfigurationViewController(tunnel: backgroundTunnel, context: editContext) } - func showProfileConfigurationViewController(profile: Profile?, context: NSManagedObjectContext) { - let profileConfigurationViewController = storyboard.instantiateViewController(type: ProfileConfigurationTableViewController.self) + func showTunnelConfigurationViewController(tunnel: Tunnel?, context: NSManagedObjectContext) { + let tunnelConfigurationViewController = storyboard.instantiateViewController(type: TunnelConfigurationTableViewController.self) - profileConfigurationViewController.viewContext = context - profileConfigurationViewController.delegate = self + tunnelConfigurationViewController.viewContext = context + tunnelConfigurationViewController.delegate = self - self.navigationController.pushViewController(profileConfigurationViewController, animated: true) + self.navigationController.pushViewController(tunnelConfigurationViewController, animated: true) } - func delete(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { + func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) { // TODO implement - print("delete profile \(profile)") + print("delete tunnel \(tunnel)") } } -extension AppCoordinator: ProfileConfigurationTableViewControllerDelegate { +extension AppCoordinator: TunnelConfigurationTableViewControllerDelegate { } diff --git a/Wireguard/Models/Interface+CoreDataProperties.swift b/Wireguard/Models/Interface+CoreDataProperties.swift index c00886a..2461514 100644 --- a/Wireguard/Models/Interface+CoreDataProperties.swift +++ b/Wireguard/Models/Interface+CoreDataProperties.swift @@ -22,7 +22,7 @@ extension Interface { @NSManaged public var mtu: Int32 @NSManaged public var dns: String? @NSManaged public var table: String? - @NSManaged public var profile: Profile? + @NSManaged public var tunnel: Tunnel? @NSManaged public var adresses: NSSet? } diff --git a/Wireguard/Models/Peer+CoreDataProperties.swift b/Wireguard/Models/Peer+CoreDataProperties.swift index 809c7fe..0308c53 100644 --- a/Wireguard/Models/Peer+CoreDataProperties.swift +++ b/Wireguard/Models/Peer+CoreDataProperties.swift @@ -20,6 +20,6 @@ extension Peer { @NSManaged public var allowedIPs: String? @NSManaged public var endpoint: String? @NSManaged public var persistentKeepalive: Int16 - @NSManaged public var profile: Profile? + @NSManaged public var tunnel: Tunnel? } diff --git a/Wireguard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents b/Wireguard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents index ef81718..929bcf5 100644 --- a/Wireguard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents +++ b/Wireguard/Models/WireGuard.xcdatamodeld/WireGuard.xcdatamodel/contents @@ -12,7 +12,7 @@ - + @@ -20,17 +20,17 @@ - + - + - - + + - - - - + + + + \ No newline at end of file