mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-10 19:47:24 +01:00
Not working because xpc service
This commit is contained in:
@@ -16,6 +16,7 @@ struct Secretive: App {
|
||||
}()
|
||||
private let agentStatusChecker = AgentStatusChecker()
|
||||
private let justUpdatedChecker = JustUpdatedChecker()
|
||||
private let updaterController = UpdaterCommunicationController()
|
||||
|
||||
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
|
||||
@State private var showingSetup = false
|
||||
@@ -28,11 +29,19 @@ struct Secretive: App {
|
||||
.environmentObject(Updater(checkOnLaunch: hasRunSetup))
|
||||
.environmentObject(agentStatusChecker)
|
||||
.onAppear {
|
||||
updaterController.configure()
|
||||
if !hasRunSetup {
|
||||
showingSetup = true
|
||||
}
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
|
||||
Task {
|
||||
do {
|
||||
let path = try await updaterController.updater?.installUpdate(url: URL(string: "https://github.com/maxgoedjen/secretive/releases/download/v2.1.1/Secretive.zip")!)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
guard hasRunSetup else { return }
|
||||
agentStatusChecker.check()
|
||||
if agentStatusChecker.running && justUpdatedChecker.justUpdated {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import AppKit
|
||||
import OSLog
|
||||
import SecretKit
|
||||
import SecretiveUpdater
|
||||
|
||||
class UpdaterCommunicationController: ObservableObject {
|
||||
|
||||
private(set) var updater: UpdaterProtocol? = nil
|
||||
private var connection: NSXPCConnection? = nil
|
||||
private var running = false
|
||||
|
||||
init() {
|
||||
}
|
||||
|
||||
func configure() {
|
||||
guard !running else { return }
|
||||
connection = NSXPCConnection(serviceName: "com.maxgoedjen.SecretiveUpdater")
|
||||
connection?.remoteObjectInterface = NSXPCInterface(with: UpdaterProtocol.self)
|
||||
connection?.invalidationHandler = {
|
||||
Logger().warning("XPC connection invalidated")
|
||||
}
|
||||
connection?.resume()
|
||||
updater = connection?.remoteObjectProxyWithErrorHandler({ error in
|
||||
Logger().error("\(String(describing: error))")
|
||||
}) as? UpdaterProtocol
|
||||
running = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user