mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-10 19:47:24 +01:00
XPC to agent working
This commit is contained in:
@@ -24,9 +24,9 @@ struct Secretive: App {
|
||||
|
||||
@SceneBuilder var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView<Updater, AgentStatusChecker>(showingCreation: $showingCreation, runningSetup: $showingSetup, hasRunSetup: $hasRunSetup)
|
||||
ContentView<UpdateChecker, AgentStatusChecker>(showingCreation: $showingCreation, runningSetup: $showingSetup, hasRunSetup: $hasRunSetup)
|
||||
.environmentObject(storeList)
|
||||
.environmentObject(Updater(checkOnLaunch: hasRunSetup))
|
||||
.environmentObject(UpdateChecker(checkOnLaunch: hasRunSetup))
|
||||
.environmentObject(agentStatusChecker)
|
||||
.onAppear {
|
||||
updaterController.configure()
|
||||
|
||||
@@ -3,7 +3,8 @@ import Combine
|
||||
import AppKit
|
||||
import OSLog
|
||||
import SecretKit
|
||||
import SecretiveUpdater
|
||||
//import SecretiveUpdater
|
||||
import ServiceManagement
|
||||
|
||||
class UpdaterCommunicationController: ObservableObject {
|
||||
|
||||
@@ -16,7 +17,10 @@ class UpdaterCommunicationController: ObservableObject {
|
||||
|
||||
func configure() {
|
||||
guard !running else { return }
|
||||
connection = NSXPCConnection(serviceName: "com.maxgoedjen.SecretiveUpdater")
|
||||
// TODO: Set disabled on launch. Only enable when I have an update to install.
|
||||
let x = SMLoginItemSetEnabled("Z72PRUAWF6.com.maxgoedjen.SecretiveUpdater" as CFString, false)
|
||||
let y = SMLoginItemSetEnabled("Z72PRUAWF6.com.maxgoedjen.SecretiveUpdater" as CFString, true)
|
||||
connection = NSXPCConnection(machServiceName: "Z72PRUAWF6.com.maxgoedjen.SecretiveUpdater")
|
||||
connection?.remoteObjectInterface = NSXPCInterface(with: UpdaterProtocol.self)
|
||||
connection?.invalidationHandler = {
|
||||
Logger().warning("XPC connection invalidated")
|
||||
@@ -25,6 +29,9 @@ class UpdaterCommunicationController: ObservableObject {
|
||||
updater = connection?.remoteObjectProxyWithErrorHandler({ error in
|
||||
Logger().error("\(String(describing: error))")
|
||||
}) as? UpdaterProtocol
|
||||
Task {
|
||||
print(try await updater?.installUpdate(url: URL(string: "https://google.com")!))
|
||||
}
|
||||
running = true
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import Foundation
|
||||
import Combine
|
||||
import Brief
|
||||
|
||||
class PreviewUpdater: UpdaterProtocol {
|
||||
class PreviewUpdater: UpdateCheckerProtocol {
|
||||
|
||||
let update: Release?
|
||||
let testBuild = false
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>$(TeamIdentifierPrefix)com.maxgoedjen.Secretive</string>
|
||||
</array>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
|
||||
@@ -4,7 +4,7 @@ import SecureEnclaveSecretKit
|
||||
import SmartCardSecretKit
|
||||
import Brief
|
||||
|
||||
struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentStatusCheckerProtocol>: View {
|
||||
struct ContentView<UpdaterType: UpdateCheckerProtocol, AgentStatusCheckerType: AgentStatusCheckerProtocol>: View {
|
||||
|
||||
@Binding var showingCreation: Bool
|
||||
@Binding var runningSetup: Bool
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import SwiftUI
|
||||
import Brief
|
||||
|
||||
struct UpdateDetailView<UpdaterType: Updater>: View {
|
||||
struct UpdateDetailView<UpdaterType: UpdateChecker>: View {
|
||||
|
||||
@EnvironmentObject var updater: UpdaterType
|
||||
|
||||
|
||||
Reference in New Issue
Block a user