UTMScripting.swift 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. //
  2. // Copyright © 2022 osy. All rights reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. // !! THIS FILE IS GENERATED FROM bridge-gen.sh, DO NOT MODIFY MANUALLY !!
  17. public enum UTMScripting: String {
  18. case application = "application"
  19. case guestFile = "guest file"
  20. case guestProcess = "guest process"
  21. case serialPort = "serial port"
  22. case virtualMachine = "virtual machine"
  23. }
  24. import AppKit
  25. import ScriptingBridge
  26. @objc public protocol SBObjectProtocol: NSObjectProtocol {
  27. func get() -> Any!
  28. }
  29. @objc public protocol SBApplicationProtocol: SBObjectProtocol {
  30. func activate()
  31. var delegate: SBApplicationDelegate! { get set }
  32. var isRunning: Bool { get }
  33. }
  34. // MARK: UTMScriptingSaveOptions
  35. @objc public enum UTMScriptingSaveOptions : AEKeyword {
  36. case yes = 0x79657320 /* 'yes ' */
  37. case no = 0x6e6f2020 /* 'no ' */
  38. case ask = 0x61736b20 /* 'ask ' */
  39. }
  40. // MARK: UTMScriptingPrintingErrorHandling
  41. @objc public enum UTMScriptingPrintingErrorHandling : AEKeyword {
  42. case standard = 0x6c777374 /* 'lwst' */
  43. case detailed = 0x6c776474 /* 'lwdt' */
  44. }
  45. // MARK: UTMScriptingBackend
  46. @objc public enum UTMScriptingBackend : AEKeyword {
  47. case apple = 0x4170506c /* 'ApPl' */
  48. case qemu = 0x51654d75 /* 'QeMu' */
  49. case unavailable = 0x556e4176 /* 'UnAv' */
  50. }
  51. // MARK: UTMScriptingStatus
  52. @objc public enum UTMScriptingStatus : AEKeyword {
  53. case stopped = 0x53745361 /* 'StSa' */
  54. case starting = 0x53745362 /* 'StSb' */
  55. case started = 0x53745363 /* 'StSc' */
  56. case pausing = 0x53745364 /* 'StSd' */
  57. case paused = 0x53745365 /* 'StSe' */
  58. case resuming = 0x53745366 /* 'StSf' */
  59. case stopping = 0x53745367 /* 'StSg' */
  60. }
  61. // MARK: UTMScriptingStopMethod
  62. @objc public enum UTMScriptingStopMethod : AEKeyword {
  63. case force = 0x466f5263 /* 'FoRc' */
  64. case kill = 0x4b694c6c /* 'KiLl' */
  65. case request = 0x52655175 /* 'ReQu' */
  66. }
  67. // MARK: UTMScriptingSerialInterface
  68. @objc public enum UTMScriptingSerialInterface : AEKeyword {
  69. case ptty = 0x50745479 /* 'PtTy' */
  70. case tcp = 0x54635020 /* 'TcP ' */
  71. case unavailable = 0x49556e41 /* 'IUnA' */
  72. }
  73. // MARK: UTMScriptingOpenMode
  74. @objc public enum UTMScriptingOpenMode : AEKeyword {
  75. case reading = 0x4f70526f /* 'OpRo' */
  76. case writing = 0x4f70576f /* 'OpWo' */
  77. case appending = 0x4f704170 /* 'OpAp' */
  78. }
  79. // MARK: UTMScriptingWhence
  80. @objc public enum UTMScriptingWhence : AEKeyword {
  81. case startPosition = 0x53745274 /* 'StRt' */
  82. case currentPosition = 0x43755272 /* 'CuRr' */
  83. case endPosition = 0x556e4176 /* 'UnAv' */
  84. }
  85. // MARK: UTMScriptingQemuDirectoryShareMode
  86. @objc public enum UTMScriptingQemuDirectoryShareMode : AEKeyword {
  87. case none = 0x536d4f66 /* 'SmOf' */
  88. case webDAV = 0x536d5776 /* 'SmWv' */
  89. case virtFS = 0x536d5673 /* 'SmVs' */
  90. }
  91. // MARK: UTMScriptingQemuDriveInterface
  92. @objc public enum UTMScriptingQemuDriveInterface : AEKeyword {
  93. case none = 0x5164494e /* 'QdIN' */
  94. case ide = 0x51644969 /* 'QdIi' */
  95. case scsi = 0x51644973 /* 'QdIs' */
  96. case sd = 0x51644964 /* 'QdId' */
  97. case mtd = 0x5164496d /* 'QdIm' */
  98. case floppy = 0x51644966 /* 'QdIf' */
  99. case pFlash = 0x51644970 /* 'QdIp' */
  100. case virtIO = 0x51644976 /* 'QdIv' */
  101. case nvMe = 0x5164496e /* 'QdIn' */
  102. case usb = 0x51644975 /* 'QdIu' */
  103. }
  104. // MARK: UTMScriptingQemuNetworkMode
  105. @objc public enum UTMScriptingQemuNetworkMode : AEKeyword {
  106. case emulated = 0x516e456d /* 'QnEm' */
  107. case shared = 0x516e5368 /* 'QnSh' */
  108. case host = 0x516e4873 /* 'QnHs' */
  109. case bridged = 0x516e4272 /* 'QnBr' */
  110. }
  111. // MARK: UTMScriptingNetworkProtocol
  112. @objc public enum UTMScriptingNetworkProtocol : AEKeyword {
  113. case tcp = 0x4e745470 /* 'NtTp' */
  114. case udp = 0x4e745570 /* 'NtUp' */
  115. }
  116. // MARK: UTMScriptingAppleNetworkMode
  117. @objc public enum UTMScriptingAppleNetworkMode : AEKeyword {
  118. case shared = 0x416e5368 /* 'AnSh' */
  119. case bridged = 0x416e4272 /* 'AnBr' */
  120. }
  121. // MARK: UTMScriptingGenericMethods
  122. @objc public protocol UTMScriptingGenericMethods {
  123. @objc optional func closeSaving(_ saving: UTMScriptingSaveOptions, savingIn: URL!) // Close a document.
  124. @objc optional func saveIn(_ in_: URL!, as: Any!) // Save a document.
  125. @objc optional func printWithProperties(_ withProperties: [AnyHashable : Any]!, printDialog: Bool) // Print a document.
  126. @objc optional func delete() // Delete an object.
  127. @objc optional func duplicateTo(_ to: SBObject!, withProperties: [AnyHashable : Any]!) // Copy an object.
  128. @objc optional func moveTo(_ to: SBObject!) // Move an object to a new location.
  129. }
  130. // MARK: UTMScriptingApplication
  131. @objc public protocol UTMScriptingApplication: SBApplicationProtocol {
  132. @objc optional func documents() -> SBElementArray
  133. @objc optional func windows() -> SBElementArray
  134. @objc optional var name: String { get } // The name of the application.
  135. @objc optional var frontmost: Bool { get } // Is this the active application?
  136. @objc optional var version: String { get } // The version number of the application.
  137. @objc optional func `open`(_ x: Any!) -> Any // Open a document.
  138. @objc optional func print(_ x: Any!, withProperties: [AnyHashable : Any]!, printDialog: Bool) // Print a document.
  139. @objc optional func quitSaving(_ saving: UTMScriptingSaveOptions) // Quit the application.
  140. @objc optional func exists(_ x: Any!) -> Bool // Verify that an object exists.
  141. @objc optional func virtualMachines() -> SBElementArray
  142. @objc optional var autoTerminate: Bool { get } // Auto terminate the application when all windows are closed?
  143. @objc optional func setAutoTerminate(_ autoTerminate: Bool) // Auto terminate the application when all windows are closed?
  144. }
  145. extension SBApplication: UTMScriptingApplication {}
  146. // MARK: UTMScriptingDocument
  147. @objc public protocol UTMScriptingDocument: SBObjectProtocol, UTMScriptingGenericMethods {
  148. @objc optional var name: String { get } // Its name.
  149. @objc optional var modified: Bool { get } // Has it been modified since the last save?
  150. @objc optional var file: URL { get } // Its location on disk, if it has one.
  151. }
  152. extension SBObject: UTMScriptingDocument {}
  153. // MARK: UTMScriptingWindow
  154. @objc public protocol UTMScriptingWindow: SBObjectProtocol, UTMScriptingGenericMethods {
  155. @objc optional var name: String { get } // The title of the window.
  156. @objc optional func id() -> Int // The unique identifier of the window.
  157. @objc optional var index: Int { get } // The index of the window, ordered front to back.
  158. @objc optional var bounds: NSRect { get } // The bounding rectangle of the window.
  159. @objc optional var closeable: Bool { get } // Does the window have a close button?
  160. @objc optional var miniaturizable: Bool { get } // Does the window have a minimize button?
  161. @objc optional var miniaturized: Bool { get } // Is the window minimized right now?
  162. @objc optional var resizable: Bool { get } // Can the window be resized?
  163. @objc optional var visible: Bool { get } // Is the window visible right now?
  164. @objc optional var zoomable: Bool { get } // Does the window have a zoom button?
  165. @objc optional var zoomed: Bool { get } // Is the window zoomed right now?
  166. @objc optional var document: UTMScriptingDocument { get } // The document whose contents are displayed in the window.
  167. @objc optional func setIndex(_ index: Int) // The index of the window, ordered front to back.
  168. @objc optional func setBounds(_ bounds: NSRect) // The bounding rectangle of the window.
  169. @objc optional func setMiniaturized(_ miniaturized: Bool) // Is the window minimized right now?
  170. @objc optional func setVisible(_ visible: Bool) // Is the window visible right now?
  171. @objc optional func setZoomed(_ zoomed: Bool) // Is the window zoomed right now?
  172. }
  173. extension SBObject: UTMScriptingWindow {}
  174. // MARK: UTMScriptingVirtualMachine
  175. @objc public protocol UTMScriptingVirtualMachine: SBObjectProtocol, UTMScriptingGenericMethods {
  176. @objc optional func serialPorts() -> SBElementArray
  177. @objc optional func id() -> String // The unique identifier of the VM.
  178. @objc optional var name: String { get } // The name of the VM.
  179. @objc optional var notes: String { get } // User specified notes.
  180. @objc optional var machine: String { get } // Target machine name.
  181. @objc optional var architecture: String { get } // Target architecture name.
  182. @objc optional var memory: String { get } // RAM size.
  183. @objc optional var backend: UTMScriptingBackend { get } // Emulation/virtualization engine used.
  184. @objc optional var status: UTMScriptingStatus { get } // Current running status.
  185. @objc optional func startSaving(_ saving: Bool) // Start a virtual machine or resume a suspended virtual machine.
  186. @objc optional func suspendSaving(_ saving: Bool) // Suspend a running virtual machine to memory.
  187. @objc optional func stopBy(_ by: UTMScriptingStopMethod) // Shuts down a running virtual machine.
  188. @objc optional func openFileAt(_ at: String!, for for_: UTMScriptingOpenMode, updating: Bool) -> UTMScriptingGuestFile // Open a file on the guest. You must close the file when you are done to prevent leaking guest resources.
  189. @objc optional func executeAt(_ at: String!, withArguments: [String]!, withEnvironment: [String]!, usingInput: String!, base64Encoding: Bool, outputCapturing: Bool) -> UTMScriptingGuestProcess // Execute a command or script on the guest.
  190. @objc optional func queryIp() -> [Any] // Query the guest for all IP addresses on its network interfaces (excluding loopback).
  191. @objc optional func updateConfigurationWith(_ with: Any!) // Update the configuration of the virtual machine. The VM must be in the stopped state.
  192. @objc optional func guestFiles() -> SBElementArray
  193. @objc optional func guestProcesses() -> SBElementArray
  194. @objc optional var configuration: Any { get } // The configuration of the virtual machine.
  195. }
  196. extension SBObject: UTMScriptingVirtualMachine {}
  197. // MARK: UTMScriptingSerialPort
  198. @objc public protocol UTMScriptingSerialPort: SBObjectProtocol, UTMScriptingGenericMethods {
  199. @objc optional func id() -> Int // The unique identifier of the tag.
  200. @objc optional var interface: UTMScriptingSerialInterface { get } // The type of serial interface on the host.
  201. @objc optional var address: String { get } // Host address of the serial port (determined by the interface type).
  202. @objc optional var port: Int { get } // Port number of the serial port (not used in some interface types).
  203. }
  204. extension SBObject: UTMScriptingSerialPort {}
  205. // MARK: UTMScriptingGuestFile
  206. @objc public protocol UTMScriptingGuestFile: SBObjectProtocol, UTMScriptingGenericMethods {
  207. @objc optional func id() -> Int // The handle for the file.
  208. @objc optional func readAtOffset(_ atOffset: Int, from: UTMScriptingWhence, forLength: Int, base64Encoding: Bool, closing: Bool) -> String // Reads text data from a guest file.
  209. @objc optional func pullTo(_ to: URL!, closing: Bool) // Pulls a file from the guest to the host.
  210. @objc optional func writeWithData(_ withData: String!, atOffset: Int, from: UTMScriptingWhence, base64Encoding: Bool, closing: Bool) // Writes text data to a guest file.
  211. @objc optional func pushFrom(_ from: URL!, closing: Bool) // Pushes a file from the host to the guest and closes it.
  212. @objc optional func close() // Closes the file and prevent further operations.
  213. }
  214. extension SBObject: UTMScriptingGuestFile {}
  215. // MARK: UTMScriptingGuestProcess
  216. @objc public protocol UTMScriptingGuestProcess: SBObjectProtocol, UTMScriptingGenericMethods {
  217. @objc optional func id() -> Int // The PID of the process.
  218. @objc optional func getResult() -> [AnyHashable : Any] // Fetch execution result from the guest.
  219. }
  220. extension SBObject: UTMScriptingGuestProcess {}