summaryrefslogtreecommitdiff
path: root/gssc.mm
diff options
context:
space:
mode:
Diffstat (limited to 'gssc.mm')
-rw-r--r--gssc.mm43
1 files changed, 36 insertions, 7 deletions
diff --git a/gssc.mm b/gssc.mm
index 0c40ed5..4932174 100644
--- a/gssc.mm
+++ b/gssc.mm
@@ -6,6 +6,16 @@
static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
+void OnGSCapabilityChanged(
+ CFNotificationCenterRef center,
+ void *observer,
+ CFStringRef name,
+ const void *object,
+ CFDictionaryRef info
+) {
+ CFRunLoopStop(CFRunLoopGetCurrent());
+}
+
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -21,15 +31,34 @@ int main(int argc, char *argv[]) {
$GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
$GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
+ CFNotificationCenterAddObserver(
+ CFNotificationCenterGetDarwinNotifyCenter(),
+ NULL,
+ &OnGSCapabilityChanged,
+ CFSTR("GSCapabilitiesChanged"),
+ NULL,
+ NULL
+ );
+
const NSArray *capability;
- if ($GSSystemCopyCapability != NULL) {
- capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name)));
- capability = [capability autorelease];
- } else if ($GSSystemGetCapability != NULL) {
- capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name)));
- } else
- capability = nil;
+ for (;;) {
+ if ($GSSystemCopyCapability != NULL) {
+ capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name)));
+ if (capability != nil)
+ capability = [capability autorelease];
+ } else if ($GSSystemGetCapability != NULL) {
+ capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name)));
+ } else {
+ capability = nil;
+ break;
+ }
+
+ if (capability != nil)
+ break;
+
+ CFRunLoopRun();
+ }
NSLog(@"%@", capability);