Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added possibility to use imported profile info for saving & upload. (…
…identifier, organisation, name, description)
  • Loading branch information
adku committed Aug 30, 2019
commit a6f7e3b90e463c329ca7918adea53b45085f103e
8 changes: 6 additions & 2 deletions Source/Model/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Model : NSObject {
}

var store: [String:Executable] = [:]
public var importedTCCProfile: TCCProfile?
}

// MARK: Loading executable
Expand Down Expand Up @@ -162,7 +163,9 @@ extension Model {

func importProfile(tccProfile: TCCProfile) {
if let content = tccProfile.content.first {
self.removeSelectedExecutables()
self.cleanUpAndRemoveDependencies()

self.importedTCCProfile = tccProfile

for (key, policies) in content.services {
getExecutablesFromAllPolicies(policies: policies)
Expand Down Expand Up @@ -243,13 +246,14 @@ extension Model {
return nil
}

private func removeSelectedExecutables() {
private func cleanUpAndRemoveDependencies() {
for executable in self.selectedExecutables {
executable.appleEvents = []
executable.policy = Policy()
}
self.selectedExecutables = []
self.current = nil
self.store.removeAll()
self.importedTCCProfile = nil
}
}
13 changes: 13 additions & 0 deletions Source/View Controllers/SaveViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class SaveViewController: NSViewController {
} catch {
print("Error loading identities: \(error)")
}

loadImportedTCCProfileInfo()
}

override func viewWillAppear() {
Expand Down Expand Up @@ -139,4 +141,15 @@ class SaveViewController: NSViewController {
self.dismiss(nil)
}

func loadImportedTCCProfileInfo() {
let model = Model.shared

if let tccProfile = model.importedTCCProfile {
organizationLabel.stringValue = tccProfile.organization
payloadName = tccProfile.displayName
payloadDescription = tccProfile.payloadDescription
payloadIdentifier = tccProfile.identifier
}
}

}
13 changes: 12 additions & 1 deletion Source/View Controllers/UploadViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class UploadViewController: NSViewController {
mustSignForUpload = UserDefaults.standard.bool(forKey: "enforceSigning")

loadCredentials()
loadImportedTCCProfileInfo()
}

override func viewWillAppear() {
Expand Down Expand Up @@ -277,7 +278,17 @@ class UploadViewController: NSViewController {
credentialsVerified = false
}


func loadImportedTCCProfileInfo() {
let model = Model.shared

if let tccProfile = model.importedTCCProfile {
organizationLabel.stringValue = tccProfile.organization
payloadName = tccProfile.displayName
payloadDescription = tccProfile.payloadDescription
payloadIdentifier = tccProfile.identifier
}
}

func syncronizeCredentials() {
if saveCredentials {
if credentialsAvailable {
Expand Down