mirror of
https://github.com/utmapp/UTM.git
synced 2026-10-12 02:24:01 +00:00
scripting: fix various issues running scripts
This commit is contained in:
@@ -36,7 +36,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public var scriptingVirtualMachines: [UTMScriptingVirtualMachineImpl] {
|
||||
@objc var scriptingVirtualMachines: [UTMScriptingVirtualMachineImpl] {
|
||||
guard let data = data else {
|
||||
return []
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.automation.apple-events</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.audio-input</key>
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
</array>
|
||||
<key>com.apple.security.device.audio-input</key>
|
||||
<true/>
|
||||
<key>com.apple.security.automation.apple-events</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.usb</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
|
||||
+7
-38
@@ -5,17 +5,6 @@
|
||||
|
||||
<suite name="Standard Suite" code="????" description="Common classes and commands for all applications.">
|
||||
|
||||
<command name="open" code="aevtodoc" description="Open a document.">
|
||||
<direct-parameter description="The file(s) to be opened.">
|
||||
<type type="file"/>
|
||||
<type type="file" list="yes"/>
|
||||
</direct-parameter>
|
||||
<result description="The opened document(s).">
|
||||
<type type="document"/>
|
||||
<type type="document" list="yes"/>
|
||||
</result>
|
||||
</command>
|
||||
|
||||
<enumeration name="printing error handling" code="enum">
|
||||
<enumerator name="standard" code="lwst" description="Standard PostScript error handling">
|
||||
<cocoa boolean-value="NO"/>
|
||||
@@ -53,15 +42,9 @@
|
||||
<cocoa key="isActive"/>
|
||||
</property>
|
||||
<property name="version" code="vers" type="text" access="r" description="The version number of the application."/>
|
||||
<element type="document">
|
||||
<cocoa key="orderedDocuments"/>
|
||||
</element>
|
||||
<element type="window" access="r">
|
||||
<cocoa key="orderedWindows"/>
|
||||
</element>
|
||||
<responds-to command="open">
|
||||
<cocoa method="handleOpenScriptCommand:"/>
|
||||
</responds-to>
|
||||
<responds-to command="quit">
|
||||
<cocoa method="handleQuitScriptCommand:"/>
|
||||
</responds-to>
|
||||
@@ -125,27 +108,13 @@
|
||||
</enumeration>
|
||||
|
||||
<enumeration name="status" code="VmEs" description="Status type.">
|
||||
<enumerator name="stopped" code="StSa" description="VM is not running.">
|
||||
<cocoa integer-value="0" />
|
||||
</enumerator>
|
||||
<enumerator name="starting" code="StSb" description="VM is starting up.">
|
||||
<cocoa integer-value="1" />
|
||||
</enumerator>
|
||||
<enumerator name="started" code="StSc" description="VM is running.">
|
||||
<cocoa integer-value="2" />
|
||||
</enumerator>
|
||||
<enumerator name="pausing" code="StSd" description="VM is going to pause.">
|
||||
<cocoa integer-value="3" />
|
||||
</enumerator>
|
||||
<enumerator name="paused" code="StSe" description="VM is paused.">
|
||||
<cocoa integer-value="4" />
|
||||
</enumerator>
|
||||
<enumerator name="resuming" code="StSf" description="VM is resuming from pause.">
|
||||
<cocoa integer-value="5" />
|
||||
</enumerator>
|
||||
<enumerator name="stopping" code="StSg" description="VM is stopping.">
|
||||
<cocoa integer-value="6" />
|
||||
</enumerator>
|
||||
<enumerator name="stopped" code="StSa" description="VM is not running."/>
|
||||
<enumerator name="starting" code="StSb" description="VM is starting up."/>
|
||||
<enumerator name="started" code="StSc" description="VM is running."/>
|
||||
<enumerator name="pausing" code="StSd" description="VM is going to pause."/>
|
||||
<enumerator name="paused" code="StSe" description="VM is paused."/>
|
||||
<enumerator name="resuming" code="StSf" description="VM is resuming from pause."/>
|
||||
<enumerator name="stopping" code="StSg" description="VM is stopping."/>
|
||||
</enumeration>
|
||||
|
||||
<enumeration name="stop method" code="VmEs" description="Stop by method.">
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
@objc class UTMScriptingSerialPortImpl: NSObject {
|
||||
private(set) var id: Int
|
||||
private(set) weak var parent: UTMScriptingVirtualMachineImpl?
|
||||
private(set) var interface: UTMScriptingSerialInterface
|
||||
private(set) var address: String
|
||||
private(set) var port: Int
|
||||
@objc(UTMScriptingSerialPortImpl)
|
||||
class UTMScriptingSerialPortImpl: NSObject {
|
||||
@objc private(set) var id: Int
|
||||
@objc private(set) weak var parent: UTMScriptingVirtualMachineImpl?
|
||||
@objc private(set) var interface: UTMScriptingSerialInterface
|
||||
@objc private(set) var address: String
|
||||
@objc private(set) var port: Int
|
||||
|
||||
init(qemuSerial: UTMQemuConfigurationSerial, parent: UTMScriptingVirtualMachineImpl, index: Int) {
|
||||
self.id = index
|
||||
|
||||
@@ -17,35 +17,36 @@
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
@objc class UTMScriptingVirtualMachineImpl: NSObject {
|
||||
@objc(UTMScriptingVirtualMachineImpl)
|
||||
class UTMScriptingVirtualMachineImpl: NSObject {
|
||||
private var vm: UTMVirtualMachine
|
||||
private var data: UTMData
|
||||
|
||||
var id: String {
|
||||
@objc var id: String {
|
||||
vm.id.uuidString
|
||||
}
|
||||
|
||||
var name: String {
|
||||
@objc var name: String {
|
||||
vm.detailsTitleLabel
|
||||
}
|
||||
|
||||
var notes: String {
|
||||
@objc var notes: String {
|
||||
vm.detailsNotes ?? ""
|
||||
}
|
||||
|
||||
var machine: String {
|
||||
@objc var machine: String {
|
||||
vm.detailsSystemTargetLabel
|
||||
}
|
||||
|
||||
var architecture: String {
|
||||
@objc var architecture: String {
|
||||
vm.detailsSystemArchitectureLabel
|
||||
}
|
||||
|
||||
var memory: String {
|
||||
@objc var memory: String {
|
||||
vm.detailsSystemMemoryLabel
|
||||
}
|
||||
|
||||
var backend: UTMScriptingBackend {
|
||||
@objc var backend: UTMScriptingBackend {
|
||||
if vm is UTMQemuVirtualMachine {
|
||||
return .qemu
|
||||
} else if vm is UTMAppleVirtualMachine {
|
||||
@@ -55,7 +56,20 @@ import Foundation
|
||||
}
|
||||
}
|
||||
|
||||
var serialPorts: [UTMScriptingSerialPortImpl] {
|
||||
@objc var status: UTMScriptingStatus {
|
||||
switch vm.state {
|
||||
case .vmStopped: return .stopped
|
||||
case .vmStarting: return .starting
|
||||
case .vmStarted: return .started
|
||||
case .vmPausing: return .pausing
|
||||
case .vmPaused: return .paused
|
||||
case .vmResuming: return .resuming
|
||||
case .vmStopping: return .stopping
|
||||
@unknown default: return .stopped
|
||||
}
|
||||
}
|
||||
|
||||
@objc var serialPorts: [UTMScriptingSerialPortImpl] {
|
||||
if let config = vm.config.qemuConfig {
|
||||
return config.serials.indices.map({ UTMScriptingSerialPortImpl(qemuSerial: config.serials[$0], parent: self, index: $0) })
|
||||
} else if let config = vm.config.appleConfig {
|
||||
@@ -66,7 +80,7 @@ import Foundation
|
||||
}
|
||||
|
||||
override var objectSpecifier: NSScriptObjectSpecifier? {
|
||||
let appDescription = NSApp.classDescription as! NSScriptClassDescription
|
||||
let appDescription = NSApplication.classDescription() as! NSScriptClassDescription
|
||||
return NSUniqueIDSpecifier(containerClassDescription: appDescription,
|
||||
containerSpecifier: nil,
|
||||
key: "scriptingVirtualMachines",
|
||||
|
||||
Reference in New Issue
Block a user