mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-10 19:47:24 +01:00
Dump
This commit is contained in:
@@ -29,19 +29,12 @@ struct Secretive: App {
|
||||
.environmentObject(UpdateChecker(checkOnLaunch: hasRunSetup))
|
||||
.environmentObject(agentStatusChecker)
|
||||
.onAppear {
|
||||
updaterController.configure()
|
||||
updaterController.installUpdate(url: URL(string: "https://github.com/maxgoedjen/secretive/releases/download/v2.1.1/Secretive.zip")!)
|
||||
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 {
|
||||
|
||||
@@ -15,12 +15,11 @@ class UpdaterCommunicationController: ObservableObject {
|
||||
init() {
|
||||
}
|
||||
|
||||
func configure() {
|
||||
func installUpdate(url: URL) {
|
||||
guard !running else { return }
|
||||
// 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")
|
||||
_ = SMLoginItemSetEnabled(Bundle.main.updaterBundleID as CFString, false)
|
||||
SMLoginItemSetEnabled(Bundle.main.updaterBundleID as CFString, true)
|
||||
connection = NSXPCConnection(machServiceName: Bundle.main.updaterBundleID)
|
||||
connection?.remoteObjectInterface = NSXPCInterface(with: UpdaterProtocol.self)
|
||||
connection?.invalidationHandler = {
|
||||
Logger().warning("XPC connection invalidated")
|
||||
@@ -29,10 +28,12 @@ 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
|
||||
let existingURL = Bundle.main.bundleURL
|
||||
Task {
|
||||
let result = try await updater?.installUpdate(url: url, to: existingURL)
|
||||
print(result)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,4 +4,5 @@ import Foundation
|
||||
extension Bundle {
|
||||
public var agentBundleID: String {(self.bundleIdentifier?.replacingOccurrences(of: "Host", with: "SecretAgent"))!}
|
||||
public var hostBundleID: String {(self.bundleIdentifier?.replacingOccurrences(of: "SecretAgent", with: "Host"))!}
|
||||
public var updaterBundleID: String { "Z72PRUAWF6.com.maxgoedjen.SecretiveUpdater" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user