LAActivator.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #import <UIKit/UIKit.h>
  2. #import <libkern/OSAtomic.h>
  3. #import "LAActivatorVersion.h"
  4. // Main event dispatcher that is responsible for sending events, maintaining the list of actions/events, and querying information about them
  5. @class LAEvent, LAListenerConfigurationViewController, LAEventConfigurationViewController;
  6. @protocol LAListener, LAEventDataSource;
  7. @interface LAActivator : NSObject LA_PRIVATE_IVARS(LAActivator)
  8. + (LAActivator *)sharedInstance;
  9. @property (nonatomic, readonly) LAActivatorVersion version;
  10. @property (nonatomic, readonly, getter=isRunningInsideSpringBoard) BOOL runningInsideSpringBoard;
  11. @property (nonatomic, readonly, getter=isDangerousToSendEvents) BOOL dangerousToSendEvents;
  12. // Listeners
  13. - (id<LAListener>)listenerForEvent:(LAEvent *)event;
  14. - (void)sendEventToListener:(LAEvent *)event;
  15. - (void)sendEvent:(LAEvent *)event toListenerWithName:(NSString *)listenerName;
  16. - (void)sendEvent:(LAEvent *)event toListenersWithNames:(NSArray *)listenerNames;
  17. - (void)sendAbortToListener:(LAEvent *)event;
  18. - (void)sendAbortEvent:(LAEvent *)event toListenerWithName:(NSString *)listenerName;
  19. - (void)sendAbortEvent:(LAEvent *)event toListenersWithNames:(NSArray *)listenerNames;
  20. - (void)sendPreviewEventToListenerWithName:(NSString *)listenerName;
  21. - (void)sendDeactivateEventToListeners:(LAEvent *)event;
  22. - (id<LAListener>)listenerForName:(NSString *)name;
  23. - (BOOL)hasListenerWithName:(NSString *)name;
  24. - (void)registerListener:(id<LAListener>)listener forName:(NSString *)name; // Only available in SpringBoard
  25. - (void)unregisterListenerWithName:(NSString *)name; // Only available in SpringBoard
  26. - (BOOL)hasSeenListenerWithName:(NSString *)name;
  27. // Assignments
  28. - (void)assignEvent:(LAEvent *)event toListenerWithName:(NSString *)listenerName;
  29. - (void)assignEvent:(LAEvent *)event toListenersWithNames:(NSArray *)listenerNames;
  30. - (void)addListenerAssignment:(NSString *)listenerName toEvent:(LAEvent *)event;
  31. - (void)removeListenerAssignment:(NSString *)listenerName fromEvent:(LAEvent *)event;
  32. - (void)unassignEvent:(LAEvent *)event;
  33. - (NSString *)assignedListenerNameForEvent:(LAEvent *)event;
  34. - (NSArray *)assignedListenerNamesForEvent:(LAEvent *)event;
  35. - (NSArray *)eventsAssignedToListenerWithName:(NSString *)listenerName;
  36. // Events
  37. @property (nonatomic, readonly) NSArray *availableEventNames;
  38. - (BOOL)hasEventWithName:(NSString *)name;
  39. - (BOOL)eventWithNameIsHidden:(NSString *)name;
  40. - (BOOL)eventWithNameRequiresAssignment:(NSString *)name;
  41. - (NSArray *)compatibleModesForEventWithName:(NSString *)name;
  42. - (BOOL)eventWithName:(NSString *)eventName isCompatibleWithMode:(NSString *)eventMode;
  43. - (BOOL)eventWithNameSupportsUnlockingDeviceToSend:(NSString *)eventName;
  44. - (BOOL)eventWithNameSupportsRemoval:(NSString *)eventName;
  45. - (void)removeEventWithName:(NSString *)eventName;
  46. - (void)registerEventDataSource:(id<LAEventDataSource>)dataSource forEventName:(NSString *)eventName;
  47. - (void)unregisterEventDataSourceWithEventName:(NSString *)eventName;
  48. - (BOOL)eventWithNameSupportsConfiguration:(NSString *)eventName;
  49. - (LAEventConfigurationViewController *)configurationViewControllerForEventWithName:(NSString *)eventName;
  50. // Listener Metadata
  51. @property (nonatomic, readonly) NSArray *availableListenerNames;
  52. - (id)infoDictionaryValueOfKey:(NSString *)key forListenerWithName:(NSString *)name;
  53. - (BOOL)listenerWithNameRequiresAssignment:(NSString *)name;
  54. - (NSArray *)compatibleEventModesForListenerWithName:(NSString *)name;
  55. - (BOOL)listenerWithName:(NSString *)listenerName isCompatibleWithMode:(NSString *)eventMode;
  56. - (BOOL)listenerWithName:(NSString *)listenerName isCompatibleWithEventName:(NSString *)eventName;
  57. - (BOOL)listenerWithNameNeedsPoweredDisplay:(NSString *)listenerName;
  58. - (NSArray *)exclusiveAssignmentGroupsForListenerName:(NSString *)listenerName;
  59. - (BOOL)listenerNamesAreMutuallyCompatible:(NSArray *)listenerNames;
  60. - (UIImage *)iconForListenerName:(NSString *)listenerName;
  61. - (UIImage *)smallIconForListenerName:(NSString *)listenerName;
  62. - (UIImage *)imageForListenerName:(NSString *)listenerName usingTemplate:(NSBundle *)templateBundle;
  63. - (BOOL)listenerWithNameSupportsRemoval:(NSString *)listenerName;
  64. - (void)requestRemovalForListenerWithName:(NSString *)listenerName;
  65. - (BOOL)listenerWithNameSupportsConfiguration:(NSString *)listenerName;
  66. - (LAListenerConfigurationViewController *)configurationViewControllerForListenerWithName:(NSString *)listenerName;
  67. // Event Modes
  68. @property (nonatomic, readonly) NSArray *availableEventModes;
  69. @property (nonatomic, readonly) NSString *currentEventMode;
  70. @property (nonatomic, readonly) NSString *currentEventModeUnderneathLockScreen;
  71. @property (nonatomic, readonly) BOOL supportsUnlockingDeviceToSendEvents;
  72. // Blacklisting
  73. @property (nonatomic, readonly) NSString *displayIdentifierForCurrentApplication;
  74. - (BOOL)applicationWithDisplayIdentifierIsBlacklisted:(NSString *)displayIdentifier;
  75. - (void)setApplicationWithDisplayIdentifier:(NSString *)displayIdentifier isBlacklisted:(BOOL)blacklisted;
  76. // Profiles
  77. @property (nonatomic, readonly) NSArray *availableProfileNames;
  78. @property (nonatomic, copy) NSString *currentProfileName;
  79. @end
  80. extern LAActivator *LASharedActivator;
  81. @interface LAActivator (Localization)
  82. - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value;
  83. - (NSString *)localizedTitleForEventMode:(NSString *)eventMode;
  84. - (NSString *)localizedTitleForEventName:(NSString *)eventName;
  85. - (NSString *)localizedTitleForListenerName:(NSString *)listenerName;
  86. - (NSString *)localizedTitleForListenerNames:(NSArray *)listenerNames;
  87. - (NSString *)localizedGroupForEventName:(NSString *)eventName;
  88. - (NSString *)localizedGroupForListenerName:(NSString *)listenerName;
  89. - (NSString *)localizedDescriptionForEventMode:(NSString *)eventMode;
  90. - (NSString *)localizedDescriptionForEventName:(NSString *)eventName;
  91. - (NSString *)localizedDescriptionForListenerName:(NSString *)listenerName;
  92. @end
  93. extern NSString * const LAEventModeSpringBoard;
  94. extern NSString * const LAEventModeApplication;
  95. extern NSString * const LAEventModeLockScreen;
  96. extern NSString * const LAActivatorAvailableListenersChangedNotification;
  97. extern NSString * const LAActivatorAvailableEventsChangedNotification;
  98. extern NSString * const LAActivatorAssignmentsChangedNotification;