UTMSpiceIO.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #import <Foundation/Foundation.h>
  17. #import "UTMSpiceIODelegate.h"
  18. #if defined(WITH_REMOTE)
  19. #import "UTMRemoteConnectInterface.h"
  20. #else
  21. @import QEMUKitInternal;
  22. #endif
  23. #if !defined(WITH_USB)
  24. @import CocoaSpiceNoUsb;
  25. #else
  26. @import CocoaSpice;
  27. #endif
  28. /// Options for initializing UTMSpiceIO
  29. typedef NS_OPTIONS(NSUInteger, UTMSpiceIOOptions) {
  30. UTMSpiceIOOptionsNone = 0,
  31. UTMSpiceIOOptionsHasAudio = (1 << 0),
  32. UTMSpiceIOOptionsHasClipboardSharing = (1 << 1),
  33. UTMSpiceIOOptionsIsShareReadOnly = (1 << 2),
  34. UTMSpiceIOOptionsHasDebugLog = (1 << 3),
  35. };
  36. NS_ASSUME_NONNULL_BEGIN
  37. #if defined(WITH_REMOTE)
  38. @interface UTMSpiceIO : NSObject<CSConnectionDelegate, UTMRemoteConnectInterface>
  39. #else
  40. @interface UTMSpiceIO : NSObject<CSConnectionDelegate, QEMUInterface>
  41. #endif
  42. @property (nonatomic, readonly, nullable) CSDisplay *primaryDisplay;
  43. @property (nonatomic, readonly, nullable) CSInput *primaryInput;
  44. @property (nonatomic, readonly, nullable) CSPort *primarySerial;
  45. @property (nonatomic, readonly) NSArray<CSDisplay *> *displays;
  46. @property (nonatomic, readonly) NSArray<CSPort *> *serials;
  47. #if defined(WITH_USB)
  48. @property (nonatomic, readonly, nullable) CSUSBManager *primaryUsbManager;
  49. #endif
  50. @property (nonatomic, weak, nullable) id<UTMSpiceIODelegate> delegate;
  51. @property (nonatomic, readonly) BOOL isConnected;
  52. @property (nonatomic, nullable) LogHandler_t logHandler;
  53. - (instancetype)init NS_UNAVAILABLE;
  54. - (instancetype)initWithSocketUrl:(NSURL *)socketUrl options:(UTMSpiceIOOptions)options NS_DESIGNATED_INITIALIZER;
  55. - (instancetype)initWithHost:(NSString *)host tlsPort:(NSInteger)tlsPort serverPublicKey:(NSData *)serverPublicKey password:(NSString *)password options:(UTMSpiceIOOptions)options NS_DESIGNATED_INITIALIZER;
  56. - (void)changeSharedDirectory:(NSURL *)url;
  57. - (BOOL)startWithError:(NSError * _Nullable *)error;
  58. - (BOOL)connectWithError:(NSError * _Nullable *)error;
  59. - (void)disconnect;
  60. - (void)screenshotWithCompletion:(screenshotCallback_t)completion;
  61. @end
  62. NS_ASSUME_NONNULL_END