1 /* Veency - VNC Remote Access Server for iPhoneOS
2 * Copyright (C) 2008-2010 Jay Freeman (saurik)
6 * Redistribution and use in source and binary
7 * forms, with or without modification, are permitted
8 * provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the
11 * above copyright notice, this list of conditions
12 * and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions
15 * and the following disclaimer in the documentation
16 * and/or other materials provided with the
18 * 3. The name of the author may not be used to endorse
19 * or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
24 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
33 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 fprintf(stderr, "_trace()@%s:%u[%s]\n", __FILE__, __LINE__, __FUNCTION__)
40 #define _likely(expr) \
41 __builtin_expect(expr, 1)
42 #define _unlikely(expr) \
43 __builtin_expect(expr, 0)
45 #include <CydiaSubstrate.h>
48 #include <rfb/keysym.h>
50 #include <mach/mach_port.h>
53 #import <QuartzCore/CAWindowServer.h>
54 #import <QuartzCore/CAWindowServerDisplay.h>
56 #import <CoreGraphics/CGGeometry.h>
57 #import <GraphicsServices/GraphicsServices.h>
58 #import <Foundation/Foundation.h>
59 #import <IOMobileFramebuffer/IOMobileFramebuffer.h>
60 #import <IOKit/IOKitLib.h>
61 #import <UIKit/UIKit.h>
63 #import <SpringBoard/SBAlertItemsController.h>
64 #import <SpringBoard/SBDismissOnlyAlertItem.h>
65 #import <SpringBoard/SBStatusBarController.h>
67 extern "C" void CoreSurfaceBufferFlushProcessorCaches(CoreSurfaceBufferRef buffer);
70 static size_t height_;
71 static NSUInteger ratio_ = 0;
73 static const size_t BytesPerPixel = 4;
74 static const size_t BitsPerSample = 8;
76 static CoreSurfaceAcceleratorRef accelerator_;
77 static CoreSurfaceBufferRef buffer_;
78 static CFDictionaryRef options_;
80 static NSMutableSet *handlers_;
81 static rfbScreenInfoPtr screen_;
86 static unsigned clients_;
88 static CFMessagePortRef ashikase_;
91 static rfbPixel *black_;
93 static void VNCBlack() {
94 if (_unlikely(black_ == NULL))
95 black_ = reinterpret_cast<rfbPixel *>(mmap(NULL, sizeof(rfbPixel) * width_ * height_, PROT_READ, MAP_ANON | MAP_PRIVATE | MAP_NOCACHE, VM_FLAGS_PURGABLE, 0));
96 screen_->frameBuffer = reinterpret_cast<char *>(black_);
99 static bool Ashikase(bool always) {
100 if (!always && !cursor_)
103 if (ashikase_ == NULL)
104 ashikase_ = CFMessagePortCreateRemote(kCFAllocatorDefault, CFSTR("jp.ashikase.mousesupport"));
105 if (ashikase_ != NULL)
112 static CFDataRef cfTrue_;
113 static CFDataRef cfFalse_;
121 static MouseEvent event_;
122 static CFDataRef cfEvent_;
125 MouseMessageTypeEvent,
126 MouseMessageTypeSetEnabled
129 static void AshikaseSendEvent(float x, float y, int buttons = 0) {
132 event_.buttons = buttons;
133 event_.absolute = true;
135 CFMessagePortSendRequest(ashikase_, MouseMessageTypeEvent, cfEvent_, 0, 0, NULL, NULL);
138 static void AshikaseSetEnabled(bool enabled, bool always) {
139 if (!Ashikase(always))
142 CFMessagePortSendRequest(ashikase_, MouseMessageTypeSetEnabled, enabled ? cfTrue_ : cfFalse_, 0, 0, NULL, NULL);
145 AshikaseSendEvent(x_, y_);
148 MSClassHook(SBAlertItemsController)
149 MSClassHook(SBStatusBarController)
152 static Class $VNCAlertItem;
154 static rfbNewClientAction action_ = RFB_CLIENT_ON_HOLD;
155 static NSCondition *condition_;
156 static NSLock *lock_;
158 static rfbClientPtr client_;
160 static void VNCSetup();
161 static void VNCEnabled();
163 @interface VNCBridge : NSObject {
166 + (void) askForConnection;
167 + (void) removeStatusBarItem;
168 + (void) registerClient;
172 @implementation VNCBridge
174 + (void) askForConnection {
175 [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$VNCAlertItem alloc] init] autorelease]];
178 + (void) removeStatusBarItem {
179 AshikaseSetEnabled(false, false);
180 [[$SBStatusBarController sharedStatusBarController] removeStatusBarItem:@"Veency"];
183 + (void) registerClient {
184 // XXX: this could find a better home
186 UIScreen *screen([UIScreen mainScreen]);
187 if ([screen respondsToSelector:@selector(scale)])
188 ratio_ = [screen scale];
194 AshikaseSetEnabled(true, false);
195 [[$SBStatusBarController sharedStatusBarController] addStatusBarItem:@"Veency"];
198 + (void) performSetup:(NSThread *)thread {
199 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
200 [thread autorelease];
208 MSInstanceMessage2(void, VNCAlertItem, alertSheet,buttonClicked, id, sheet, int, button) {
213 action_ = RFB_CLIENT_ACCEPT;
215 @synchronized (condition_) {
216 [VNCBridge registerClient];
221 action_ = RFB_CLIENT_REFUSE;
230 MSInstanceMessage2(void, VNCAlertItem, configure,requirePasscodeForActions, BOOL, configure, BOOL, require) {
231 UIModalView *sheet([self alertSheet]);
232 [sheet setDelegate:self];
233 [sheet setTitle:@"Remote Access Request"];
234 [sheet setBodyText:[NSString stringWithFormat:@"Accept connection from\n%s?\n\nVeency VNC Server\nby Jay Freeman (saurik)\nsaurik@saurik.com\nhttp://www.saurik.com/\n\nSet a VNC password in Settings!", client_->host]];
235 [sheet addButtonWithTitle:@"Accept"];
236 [sheet addButtonWithTitle:@"Reject"];
239 MSInstanceMessage0(void, VNCAlertItem, performUnlockAction) {
240 [[$SBAlertItemsController sharedInstance] activateAlertItem:self];
243 static mach_port_t (*GSTakePurpleSystemEventPort)(void);
244 static bool PurpleAllocated;
247 static void FixRecord(GSEventRecord *record) {
249 memmove(&record->windowContextId, &record->windowContextId + 1, sizeof(*record) - (reinterpret_cast<uint8_t *>(&record->windowContextId + 1) - reinterpret_cast<uint8_t *>(record)) + record->size);
252 static void VNCSettings() {
253 NSDictionary *settings([NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]]);
255 @synchronized (lock_) {
256 for (NSValue *handler in handlers_)
257 rfbUnregisterSecurityHandler(reinterpret_cast<rfbSecurityHandler *>([handler pointerValue]));
258 [handlers_ removeAllObjects];
261 @synchronized (condition_) {
265 [reinterpret_cast<NSString *>(screen_->authPasswdData) release];
266 screen_->authPasswdData = NULL;
269 if (NSString *password = [settings objectForKey:@"Password"])
270 if ([password length] != 0)
271 screen_->authPasswdData = [password retain];
273 NSNumber *cursor = [settings objectForKey:@"ShowCursor"];
274 cursor_ = cursor == nil ? true : [cursor boolValue];
277 AshikaseSetEnabled(cursor_, true);
281 static void VNCNotifySettings(
282 CFNotificationCenterRef center,
291 static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size) {
292 @synchronized (condition_) {
293 if (NSString *password = reinterpret_cast<NSString *>(screen_->authPasswdData)) {
294 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
295 rfbEncryptBytes(client->authChallenge, const_cast<char *>([password UTF8String]));
296 bool good(memcmp(client->authChallenge, data, size) == 0);
303 static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
309 CGPoint location = {x, y};
311 if (width_ > height_) {
313 x = height_ / ratio_ - 1 - y;
318 int diff = buttons_ ^ buttons;
319 bool twas((buttons_ & 0x1) != 0);
320 bool tis((buttons & 0x1) != 0);
323 rfbDefaultPtrAddEvent(buttons, x, y, client);
325 if (Ashikase(false)) {
326 AshikaseSendEvent(x, y, buttons);
330 mach_port_t purple(0);
332 if ((diff & 0x10) != 0) {
333 struct GSEventRecord record;
335 memset(&record, 0, sizeof(record));
337 record.type = (buttons & 0x4) != 0 ?
338 GSEventTypeHeadsetButtonDown :
339 GSEventTypeHeadsetButtonUp;
341 record.timestamp = GSCurrentEventTimestamp();
344 GSSendSystemEvent(&record);
347 if ((diff & 0x04) != 0) {
348 struct GSEventRecord record;
350 memset(&record, 0, sizeof(record));
352 record.type = (buttons & 0x4) != 0 ?
353 GSEventTypeMenuButtonDown :
354 GSEventTypeMenuButtonUp;
356 record.timestamp = GSCurrentEventTimestamp();
359 GSSendSystemEvent(&record);
362 if ((diff & 0x02) != 0) {
363 struct GSEventRecord record;
365 memset(&record, 0, sizeof(record));
367 record.type = (buttons & 0x2) != 0 ?
368 GSEventTypeLockButtonDown :
369 GSEventTypeLockButtonUp;
371 record.timestamp = GSCurrentEventTimestamp();
374 GSSendSystemEvent(&record);
377 if (twas != tis || tis) {
379 struct GSEventRecord record;
381 struct GSEventRecordInfo info;
382 struct GSPathInfo path;
386 memset(&event, 0, sizeof(event));
388 event.record.type = GSEventTypeMouse;
389 event.record.locationInWindow.x = x;
390 event.record.locationInWindow.y = y;
391 event.record.timestamp = GSCurrentEventTimestamp();
392 event.record.size = sizeof(event.data);
394 event.data.info.handInfo.type = twas == tis ?
395 GSMouseEventTypeDragged :
397 GSMouseEventTypeDown :
400 event.data.info.handInfo.x34 = 0x1;
401 event.data.info.handInfo.x38 = tis ? 0x1 : 0x0;
403 event.data.info.pathPositions = 1;
405 event.data.path.x00 = 0x01;
406 event.data.path.x01 = 0x02;
407 event.data.path.x02 = tis ? 0x03 : 0x00;
408 event.data.path.position = event.record.locationInWindow;
412 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
413 NSArray *displays([server displays]);
414 if (displays != nil && [displays count] != 0)
415 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
416 port = [display clientPortAtPosition:location];
421 purple = (*GSTakePurpleSystemEventPort)();
425 FixRecord(&event.record);
426 GSSendEvent(&event.record, port);
429 if (purple != 0 && PurpleAllocated)
430 mach_port_deallocate(mach_task_self(), purple);
433 GSEventRef (*$GSEventCreateKeyEvent)(int, CGPoint, CFStringRef, CFStringRef, id, UniChar, short, short);
434 GSEventRef (*$GSCreateSyntheticKeyEvent)(UniChar, BOOL, BOOL);
436 static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
441 case XK_Return: key = '\r'; break;
442 case XK_BackSpace: key = 0x7f; break;
448 CGPoint point(CGPointMake(x_, y_));
450 UniChar unicode(key);
451 CFStringRef string(NULL);
453 GSEventRef event0, event1(NULL);
454 if ($GSEventCreateKeyEvent != NULL) {
455 string = CFStringCreateWithCharacters(kCFAllocatorDefault, &unicode, 1);
456 event0 = (*$GSEventCreateKeyEvent)(10, point, string, string, nil, 0, 0, 1);
457 event1 = (*$GSEventCreateKeyEvent)(11, point, string, string, nil, 0, 0, 1);
458 } else if ($GSCreateSyntheticKeyEvent != NULL) {
459 event0 = (*$GSCreateSyntheticKeyEvent)(unicode, YES, YES);
460 GSEventRecord *record(_GSEventGetGSEventRecord(event0));
461 record->type = GSEventTypeKeyDown;
466 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
467 NSArray *displays([server displays]);
468 if (displays != nil && [displays count] != 0)
469 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
470 port = [display clientPortAtPosition:point];
473 mach_port_t purple(0);
477 purple = (*GSTakePurpleSystemEventPort)();
482 GSSendEvent(_GSEventGetGSEventRecord(event0), port);
484 GSSendEvent(_GSEventGetGSEventRecord(event1), port);
487 if (purple != 0 && PurpleAllocated)
488 mach_port_deallocate(mach_task_self(), purple);
497 static void VNCDisconnect(rfbClientPtr client) {
498 @synchronized (condition_) {
500 [VNCBridge performSelectorOnMainThread:@selector(removeStatusBarItem) withObject:nil waitUntilDone:YES];
504 static rfbNewClientAction VNCClient(rfbClientPtr client) {
505 @synchronized (condition_) {
506 if (screen_->authPasswdData != NULL) {
507 [VNCBridge performSelectorOnMainThread:@selector(registerClient) withObject:nil waitUntilDone:YES];
508 client->clientGoneHook = &VNCDisconnect;
509 return RFB_CLIENT_ACCEPT;
515 [VNCBridge performSelectorOnMainThread:@selector(askForConnection) withObject:nil waitUntilDone:NO];
516 while (action_ == RFB_CLIENT_ON_HOLD)
518 rfbNewClientAction action(action_);
519 action_ = RFB_CLIENT_ON_HOLD;
522 if (action == RFB_CLIENT_ACCEPT)
523 client->clientGoneHook = &VNCDisconnect;
527 extern "C" bool GSSystemHasCapability(NSString *);
529 static CFTypeRef (*$GSSystemCopyCapability)(CFStringRef);
530 static CFTypeRef (*$GSSystemGetCapability)(CFStringRef);
532 static void VNCSetup() {
535 @synchronized (condition_) {
537 char *arg0(strdup("VNCServer"));
538 char *argv[] = {arg0, NULL};
539 screen_ = rfbGetScreen(&argc, argv, width_, height_, BitsPerSample, 3, BytesPerPixel);
545 screen_->desktopName = strdup([[[NSProcessInfo processInfo] hostName] UTF8String]);
547 screen_->alwaysShared = TRUE;
548 screen_->handleEventsEagerly = TRUE;
549 screen_->deferUpdateTime = 1000 / 25;
551 screen_->serverFormat.redShift = BitsPerSample * 2;
552 screen_->serverFormat.greenShift = BitsPerSample * 1;
553 screen_->serverFormat.blueShift = BitsPerSample * 0;
555 $GSSystemCopyCapability = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
556 $GSSystemGetCapability = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
560 if ($GSSystemCopyCapability != NULL) {
561 opengles2 = (*$GSSystemCopyCapability)(CFSTR("opengles-2"));
562 } else if ($GSSystemGetCapability != NULL) {
563 opengles2 = (*$GSSystemGetCapability)(CFSTR("opengles-2"));
564 if (opengles2 != NULL)
569 bool accelerated(opengles2 != NULL && [(NSNumber *)opengles2 boolValue]);
573 CoreSurfaceAcceleratorCreate(NULL, NULL, &accelerator_);
575 if (opengles2 != NULL)
576 CFRelease(opengles2);
578 if (accelerator_ != NULL)
579 buffer_ = CoreSurfaceBufferCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:
580 @"PurpleEDRAM", kCoreSurfaceBufferMemoryRegion,
581 [NSNumber numberWithBool:YES], kCoreSurfaceBufferGlobal,
582 [NSNumber numberWithInt:(width_ * BytesPerPixel)], kCoreSurfaceBufferPitch,
583 [NSNumber numberWithInt:width_], kCoreSurfaceBufferWidth,
584 [NSNumber numberWithInt:height_], kCoreSurfaceBufferHeight,
585 [NSNumber numberWithInt:'BGRA'], kCoreSurfaceBufferPixelFormat,
586 [NSNumber numberWithInt:(width_ * height_ * BytesPerPixel)], kCoreSurfaceBufferAllocSize,
591 //screen_->frameBuffer = reinterpret_cast<char *>(mmap(NULL, sizeof(rfbPixel) * width_ * height_, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_NOCACHE, VM_FLAGS_PURGABLE, 0));
593 CoreSurfaceBufferLock(buffer_, 3);
594 screen_->frameBuffer = reinterpret_cast<char *>(CoreSurfaceBufferGetBaseAddress(buffer_));
595 CoreSurfaceBufferUnlock(buffer_);
597 screen_->kbdAddEvent = &VNCKeyboard;
598 screen_->ptrAddEvent = &VNCPointer;
600 screen_->newClientHook = &VNCClient;
601 screen_->passwordCheck = &VNCCheck;
603 screen_->cursor = NULL;
606 static void VNCEnabled() {
610 if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]])
611 if (NSNumber *number = [settings objectForKey:@"Enabled"])
612 enabled = [number boolValue];
614 if (enabled != running_)
617 screen_->socketState = RFB_SOCKET_INIT;
618 rfbInitServer(screen_);
619 rfbRunEventLoop(screen_, -1, true);
621 rfbShutdownServer(screen_, true);
628 static void VNCNotifyEnabled(
629 CFNotificationCenterRef center,
638 void (*$IOMobileFramebufferIsMainDisplay)(IOMobileFramebufferRef, bool *);
640 static IOMobileFramebufferRef main_;
641 static CoreSurfaceBufferRef layer_;
643 static void OnLayer(IOMobileFramebufferRef fb, CoreSurfaceBufferRef layer) {
644 if (_unlikely(width_ == 0 || height_ == 0)) {
646 IOMobileFramebufferGetDisplaySize(fb, &size);
649 height_ = size.height;
651 if (width_ == 0 || height_ == 0)
654 NSThread *thread([NSThread alloc]);
657 initWithTarget:[VNCBridge class]
658 selector:@selector(performSetup:)
663 } else if (_unlikely(clients_ != 0)) {
665 if (accelerator_ != NULL)
666 memset(screen_->frameBuffer, 0, sizeof(rfbPixel) * width_ * height_);
670 if (accelerator_ != NULL)
671 CoreSurfaceAcceleratorTransferSurface(accelerator_, layer, buffer_, options_);
673 CoreSurfaceBufferLock(layer, 2);
674 rfbPixel *data(reinterpret_cast<rfbPixel *>(CoreSurfaceBufferGetBaseAddress(layer)));
676 CoreSurfaceBufferFlushProcessorCaches(layer);
678 /*rfbPixel corner(data[0]);
682 screen_->frameBuffer = const_cast<char *>(reinterpret_cast<volatile char *>(data));
683 CoreSurfaceBufferUnlock(layer);
687 rfbMarkRectAsModified(screen_, 0, 0, width_, height_);
691 static bool wait_ = false;
693 MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer,
694 IOMobileFramebufferRef fb,
696 CoreSurfaceBufferRef buffer,
703 if (_unlikely(buffer == NULL))
705 else if (_unlikely(fb == NULL))
707 else if ($IOMobileFramebufferIsMainDisplay == NULL)
710 (*$IOMobileFramebufferIsMainDisplay)(fb, &main);
720 return _IOMobileFramebufferSwapSetLayer(fb, layer, buffer, bounds, frame, flags);
723 // XXX: beg rpetrich for the type of this function
724 extern "C" void *IOMobileFramebufferSwapWait(IOMobileFramebufferRef, void *, unsigned);
726 MSHook(void *, IOMobileFramebufferSwapWait, IOMobileFramebufferRef fb, void *arg1, unsigned flags) {
727 void *value(_IOMobileFramebufferSwapWait(fb, arg1, flags));
733 MSHook(void, rfbRegisterSecurityHandler, rfbSecurityHandler *handler) {
734 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
736 @synchronized (lock_) {
737 [handlers_ addObject:[NSValue valueWithPointer:handler]];
738 _rfbRegisterSecurityHandler(handler);
744 template <typename Type_>
745 static void dlset(Type_ &function, const char *name) {
746 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
750 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
752 MSHookSymbol(GSTakePurpleSystemEventPort, "GSGetPurpleSystemEventPort");
753 if (GSTakePurpleSystemEventPort == NULL) {
754 MSHookSymbol(GSTakePurpleSystemEventPort, "GSCopyPurpleSystemEventPort");
755 PurpleAllocated = true;
758 if (dlsym(RTLD_DEFAULT, "GSKeyboardCreate") != NULL)
760 else if (dlsym(RTLD_DEFAULT, "GSEventGetWindowContextId") != NULL)
765 dlset($GSEventCreateKeyEvent, "GSEventCreateKeyEvent");
766 dlset($GSCreateSyntheticKeyEvent, "_GSCreateSyntheticKeyEvent");
767 dlset($IOMobileFramebufferIsMainDisplay, "IOMobileFramebufferIsMainDisplay");
769 MSHookFunction(&IOMobileFramebufferSwapSetLayer, MSHake(IOMobileFramebufferSwapSetLayer));
770 MSHookFunction(&rfbRegisterSecurityHandler, MSHake(rfbRegisterSecurityHandler));
773 MSHookFunction(&IOMobileFramebufferSwapWait, MSHake(IOMobileFramebufferSwapWait));
775 $VNCAlertItem = objc_allocateClassPair(objc_getClass("SBAlertItem"), "VNCAlertItem", 0);
776 MSAddMessage2(VNCAlertItem, "v@:@i", alertSheet,buttonClicked);
777 MSAddMessage2(VNCAlertItem, "v@:cc", configure,requirePasscodeForActions);
778 MSAddMessage0(VNCAlertItem, "v@:", performUnlockAction);
779 objc_registerClassPair($VNCAlertItem);
781 CFNotificationCenterAddObserver(
782 CFNotificationCenterGetDarwinNotifyCenter(),
783 NULL, &VNCNotifyEnabled, CFSTR("com.saurik.Veency-Enabled"), NULL, 0
786 CFNotificationCenterAddObserver(
787 CFNotificationCenterGetDarwinNotifyCenter(),
788 NULL, &VNCNotifySettings, CFSTR("com.saurik.Veency-Settings"), NULL, 0
791 condition_ = [[NSCondition alloc] init];
792 lock_ = [[NSLock alloc] init];
793 handlers_ = [[NSMutableSet alloc] init];
798 cfTrue_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
801 cfFalse_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
803 cfEvent_ = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&event_), sizeof(event_), kCFAllocatorNull);
805 options_ = (CFDictionaryRef) [[NSDictionary dictionaryWithObjectsAndKeys: