2
0

UTMScripting.swift 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 usbDevice = "usb device"
  23. case virtualMachine = "virtual machine"
  24. }
  25. import AppKit
  26. import ScriptingBridge
  27. @objc public protocol SBObjectProtocol: NSObjectProtocol {
  28. func get() -> Any!
  29. }
  30. @objc public protocol SBApplicationProtocol: SBObjectProtocol {
  31. func activate()
  32. var delegate: SBApplicationDelegate! { get set }
  33. var isRunning: Bool { get }
  34. }
  35. // MARK: UTMScriptingSaveOptions
  36. @objc public enum UTMScriptingSaveOptions : AEKeyword {
  37. case yes = 0x79657320 /* 'yes ' */
  38. case no = 0x6e6f2020 /* 'no ' */
  39. case ask = 0x61736b20 /* 'ask ' */
  40. }
  41. // MARK: UTMScriptingPrintingErrorHandling
  42. @objc public enum UTMScriptingPrintingErrorHandling : AEKeyword {
  43. case standard = 0x6c777374 /* 'lwst' */
  44. case detailed = 0x6c776474 /* 'lwdt' */
  45. }
  46. // MARK: UTMScriptingBackend
  47. @objc public enum UTMScriptingBackend : AEKeyword {
  48. case apple = 0x4170506c /* 'ApPl' */
  49. case qemu = 0x51654d75 /* 'QeMu' */
  50. case unavailable = 0x556e4176 /* 'UnAv' */
  51. }
  52. // MARK: UTMScriptingStatus
  53. @objc public enum UTMScriptingStatus : AEKeyword {
  54. case stopped = 0x53745361 /* 'StSa' */
  55. case starting = 0x53745362 /* 'StSb' */
  56. case started = 0x53745363 /* 'StSc' */
  57. case pausing = 0x53745364 /* 'StSd' */
  58. case paused = 0x53745365 /* 'StSe' */
  59. case resuming = 0x53745366 /* 'StSf' */
  60. case stopping = 0x53745367 /* 'StSg' */
  61. }
  62. // MARK: UTMScriptingStopMethod
  63. @objc public enum UTMScriptingStopMethod : AEKeyword {
  64. case force = 0x466f5263 /* 'FoRc' */
  65. case kill = 0x4b694c6c /* 'KiLl' */
  66. case request = 0x52655175 /* 'ReQu' */
  67. }
  68. // MARK: UTMScriptingSerialInterface
  69. @objc public enum UTMScriptingSerialInterface : AEKeyword {
  70. case ptty = 0x50745479 /* 'PtTy' */
  71. case tcp = 0x54635020 /* 'TcP ' */
  72. case unavailable = 0x49556e41 /* 'IUnA' */
  73. }
  74. // MARK: UTMScriptingOpenMode
  75. @objc public enum UTMScriptingOpenMode : AEKeyword {
  76. case reading = 0x4f70526f /* 'OpRo' */
  77. case writing = 0x4f70576f /* 'OpWo' */
  78. case appending = 0x4f704170 /* 'OpAp' */
  79. }
  80. // MARK: UTMScriptingWhence
  81. @objc public enum UTMScriptingWhence : AEKeyword {
  82. case startPosition = 0x53745274 /* 'StRt' */
  83. case currentPosition = 0x43755272 /* 'CuRr' */
  84. case endPosition = 0x556e4176 /* 'UnAv' */
  85. }
  86. // MARK: UTMScriptingQemuDirectoryShareMode
  87. @objc public enum UTMScriptingQemuDirectoryShareMode : AEKeyword {
  88. case none = 0x536d4f66 /* 'SmOf' */
  89. case webDAV = 0x536d5776 /* 'SmWv' */
  90. case virtFS = 0x536d5673 /* 'SmVs' */
  91. }
  92. // MARK: UTMScriptingQemuDriveInterface
  93. @objc public enum UTMScriptingQemuDriveInterface : AEKeyword {
  94. case none = 0x5164494e /* 'QdIN' */
  95. case ide = 0x51644969 /* 'QdIi' */
  96. case scsi = 0x51644973 /* 'QdIs' */
  97. case sd = 0x51644964 /* 'QdId' */
  98. case mtd = 0x5164496d /* 'QdIm' */
  99. case floppy = 0x51644966 /* 'QdIf' */
  100. case pFlash = 0x51644970 /* 'QdIp' */
  101. case virtIO = 0x51644976 /* 'QdIv' */
  102. case nvMe = 0x5164496e /* 'QdIn' */
  103. case usb = 0x51644975 /* 'QdIu' */
  104. }
  105. // MARK: UTMScriptingQemuNetworkMode
  106. @objc public enum UTMScriptingQemuNetworkMode : AEKeyword {
  107. case emulated = 0x456d5564 /* 'EmUd' */
  108. case shared = 0x53685264 /* 'ShRd' */
  109. case host = 0x486f5374 /* 'HoSt' */
  110. case bridged = 0x42724764 /* 'BrGd' */
  111. }
  112. // MARK: UTMScriptingNetworkProtocol
  113. @objc public enum UTMScriptingNetworkProtocol : AEKeyword {
  114. case tcp = 0x54635070 /* 'TcPp' */
  115. case udp = 0x55645070 /* 'UdPp' */
  116. }
  117. // MARK: UTMScriptingAppleNetworkMode
  118. @objc public enum UTMScriptingAppleNetworkMode : AEKeyword {
  119. case shared = 0x53685264 /* 'ShRd' */
  120. case bridged = 0x42724764 /* 'BrGd' */
  121. }
  122. // MARK: UTMScriptingGenericMethods
  123. @objc public protocol UTMScriptingGenericMethods {
  124. @objc optional func closeSaving(_ saving: UTMScriptingSaveOptions, savingIn: URL!) // Close a document.
  125. @objc optional func saveIn(_ in_: URL!, as: Any!) // Save a document.
  126. @objc optional func printWithProperties(_ withProperties: [AnyHashable : Any]!, printDialog: Bool) // Print a document.
  127. @objc optional func delete() // Delete an object.
  128. @objc optional func duplicateTo(_ to: SBObject!, withProperties: [AnyHashable : Any]!) // Copy an object.
  129. @objc optional func moveTo(_ to: SBObject!) // Move an object to a new location.
  130. }
  131. // MARK: UTMScriptingApplication
  132. @objc public protocol UTMScriptingApplication: SBApplicationProtocol {
  133. @objc optional func documents() -> SBElementArray
  134. @objc optional func windows() -> SBElementArray
  135. @objc optional var name: String { get } // The name of the application.
  136. @objc optional var frontmost: Bool { get } // Is this the active application?
  137. @objc optional var version: String { get } // The version number of the application.
  138. @objc optional func `open`(_ x: Any!) -> Any // Open a document.
  139. @objc optional func print(_ x: Any!, withProperties: [AnyHashable : Any]!, printDialog: Bool) // Print a document.
  140. @objc optional func quitSaving(_ saving: UTMScriptingSaveOptions) // Quit the application.
  141. @objc optional func exists(_ x: Any!) -> Bool // Verify that an object exists.
  142. @objc optional func virtualMachines() -> SBElementArray
  143. @objc optional var autoTerminate: Bool { get } // Auto terminate the application when all windows are closed?
  144. @objc optional func setAutoTerminate(_ autoTerminate: Bool) // Auto terminate the application when all windows are closed?
  145. @objc optional func usbDevices() -> SBElementArray
  146. }
  147. extension SBApplication: UTMScriptingApplication {}
  148. // MARK: UTMScriptingDocument
  149. @objc public protocol UTMScriptingDocument: SBObjectProtocol, UTMScriptingGenericMethods {
  150. @objc optional var name: String { get } // Its name.
  151. @objc optional var modified: Bool { get } // Has it been modified since the last save?
  152. @objc optional var file: URL { get } // Its location on disk, if it has one.
  153. }
  154. extension SBObject: UTMScriptingDocument {}
  155. // MARK: UTMScriptingWindow
  156. @objc public protocol UTMScriptingWindow: SBObjectProtocol, UTMScriptingGenericMethods {
  157. @objc optional var name: String { get } // The title of the window.
  158. @objc optional func id() -> Int // The unique identifier of the window.
  159. @objc optional var index: Int { get } // The index of the window, ordered front to back.
  160. @objc optional var bounds: NSRect { get } // The bounding rectangle of the window.
  161. @objc optional var closeable: Bool { get } // Does the window have a close button?
  162. @objc optional var miniaturizable: Bool { get } // Does the window have a minimize button?
  163. @objc optional var miniaturized: Bool { get } // Is the window minimized right now?
  164. @objc optional var resizable: Bool { get } // Can the window be resized?
  165. @objc optional var visible: Bool { get } // Is the window visible right now?
  166. @objc optional var zoomable: Bool { get } // Does the window have a zoom button?
  167. @objc optional var zoomed: Bool { get } // Is the window zoomed right now?
  168. @objc optional var document: UTMScriptingDocument { get } // The document whose contents are displayed in the window.
  169. @objc optional func setIndex(_ index: Int) // The index of the window, ordered front to back.
  170. @objc optional func setBounds(_ bounds: NSRect) // The bounding rectangle of the window.
  171. @objc optional func setMiniaturized(_ miniaturized: Bool) // Is the window minimized right now?
  172. @objc optional func setVisible(_ visible: Bool) // Is the window visible right now?
  173. @objc optional func setZoomed(_ zoomed: Bool) // Is the window zoomed right now?
  174. }
  175. extension SBObject: UTMScriptingWindow {}
  176. // MARK: UTMScriptingVirtualMachine
  177. @objc public protocol UTMScriptingVirtualMachine: SBObjectProtocol, UTMScriptingGenericMethods {
  178. @objc optional func serialPorts() -> SBElementArray
  179. @objc optional func id() -> String // The unique identifier of the VM.
  180. @objc optional var name: String { get } // The name of the VM.
  181. @objc optional var backend: UTMScriptingBackend { get } // Emulation/virtualization engine used.
  182. @objc optional var status: UTMScriptingStatus { get } // Current running status.
  183. @objc optional func startSaving(_ saving: Bool) // Start a virtual machine or resume a suspended virtual machine.
  184. @objc optional func suspendSaving(_ saving: Bool) // Suspend a running virtual machine to memory.
  185. @objc optional func stopBy(_ by: UTMScriptingStopMethod) // Shuts down a running virtual machine.
  186. @objc optional func delete() // Delete a virtual machine. All data will be deleted, there is no confirmation!
  187. @objc optional func duplicateWithProperties(_ withProperties: [AnyHashable : Any]!) // Copy an virtual machine and all its data.
  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. @objc optional func usbDevices() -> SBElementArray
  196. }
  197. extension SBObject: UTMScriptingVirtualMachine {}
  198. // MARK: UTMScriptingSerialPort
  199. @objc public protocol UTMScriptingSerialPort: SBObjectProtocol, UTMScriptingGenericMethods {
  200. @objc optional func id() -> Int // The unique identifier of the tag.
  201. @objc optional var interface: UTMScriptingSerialInterface { get } // The type of serial interface on the host.
  202. @objc optional var address: String { get } // Host address of the serial port (determined by the interface type).
  203. @objc optional var port: Int { get } // Port number of the serial port (not used in some interface types).
  204. }
  205. extension SBObject: UTMScriptingSerialPort {}
  206. // MARK: UTMScriptingGuestFile
  207. @objc public protocol UTMScriptingGuestFile: SBObjectProtocol, UTMScriptingGenericMethods {
  208. @objc optional func id() -> Int // The handle for the file.
  209. @objc optional func readAtOffset(_ atOffset: Int, from: UTMScriptingWhence, forLength: Int, base64Encoding: Bool, closing: Bool) -> String // Reads text data from a guest file.
  210. @objc optional func pullTo(_ to: URL!, closing: Bool) // Pulls a file from the guest to the host.
  211. @objc optional func writeWithData(_ withData: String!, atOffset: Int, from: UTMScriptingWhence, base64Encoding: Bool, closing: Bool) // Writes text data to a guest file.
  212. @objc optional func pushFrom(_ from: URL!, closing: Bool) // Pushes a file from the host to the guest and closes it.
  213. @objc optional func close() // Closes the file and prevent further operations.
  214. }
  215. extension SBObject: UTMScriptingGuestFile {}
  216. // MARK: UTMScriptingGuestProcess
  217. @objc public protocol UTMScriptingGuestProcess: SBObjectProtocol, UTMScriptingGenericMethods {
  218. @objc optional func id() -> Int // The PID of the process.
  219. @objc optional func getResult() -> [AnyHashable : Any] // Fetch execution result from the guest.
  220. }
  221. extension SBObject: UTMScriptingGuestProcess {}
  222. // MARK: UTMScriptingUsbDevice
  223. @objc public protocol UTMScriptingUsbDevice: SBObjectProtocol, UTMScriptingGenericMethods {
  224. @objc optional func id() -> Int // A unique identifier corrosponding to the USB bus and port number.
  225. @objc optional var name: String { get } // The name of the USB device.
  226. @objc optional var manufacturerName: String { get } // The product name described by the iManufacturer descriptor.
  227. @objc optional var productName: String { get } // The product name described by the iProduct descriptor.
  228. @objc optional var vendorId: Int { get } // The vendor ID described by the idVendor descriptor.
  229. @objc optional var productId: Int { get } // The product ID described by the idProduct descriptor.
  230. @objc optional func connectTo(_ to: UTMScriptingVirtualMachine!) // Connect a USB device to a running VM and remove it from the host.
  231. @objc optional func disconnect() // Disconnect a USB device from the guest and re-assign it to the host.
  232. }
  233. extension SBObject: UTMScriptingUsbDevice {}