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>
52 #include <sys/sysctl.h>
54 #import <QuartzCore/CAWindowServer.h>
55 #import <QuartzCore/CAWindowServerDisplay.h>
57 #import <CoreGraphics/CGGeometry.h>
58 #import <GraphicsServices/GraphicsServices.h>
59 #import <Foundation/Foundation.h>
60 #import <IOMobileFramebuffer/IOMobileFramebuffer.h>
61 #import <IOKit/IOKitLib.h>
62 #import <UIKit/UIKit.h>
64 #import <SpringBoard/SBAlertItemsController.h>
65 #import <SpringBoard/SBDismissOnlyAlertItem.h>
66 #import <SpringBoard/SBStatusBarController.h>
68 extern "C" void CoreSurfaceBufferFlushProcessorCaches(CoreSurfaceBufferRef buffer);
71 static size_t height_;
72 static NSUInteger ratio_ = 0;
74 static const size_t BytesPerPixel = 4;
75 static const size_t BitsPerSample = 8;
77 static CoreSurfaceAcceleratorRef accelerator_;
78 static CoreSurfaceBufferRef buffer_;
79 static CFDictionaryRef options_;
81 static NSMutableSet *handlers_;
82 static rfbScreenInfoPtr screen_;
87 static unsigned clients_;
89 static CFMessagePortRef ashikase_;
92 static rfbPixel *black_;
94 static void VNCBlack() {
95 if (_unlikely(black_ == NULL))
96 black_ = reinterpret_cast<rfbPixel *>(mmap(NULL, sizeof(rfbPixel) * width_ * height_, PROT_READ, MAP_ANON | MAP_PRIVATE | MAP_NOCACHE, VM_FLAGS_PURGABLE, 0));
97 screen_->frameBuffer = reinterpret_cast<char *>(black_);
100 static bool Ashikase(bool always) {
101 if (!always && !cursor_)
104 if (ashikase_ == NULL)
105 ashikase_ = CFMessagePortCreateRemote(kCFAllocatorDefault, CFSTR("jp.ashikase.mousesupport"));
106 if (ashikase_ != NULL)
113 static CFDataRef cfTrue_;
114 static CFDataRef cfFalse_;
122 static MouseEvent event_;
123 static CFDataRef cfEvent_;
126 MouseMessageTypeEvent,
127 MouseMessageTypeSetEnabled
130 static void AshikaseSendEvent(float x, float y, int buttons = 0) {
133 event_.buttons = buttons;
134 event_.absolute = true;
136 CFMessagePortSendRequest(ashikase_, MouseMessageTypeEvent, cfEvent_, 0, 0, NULL, NULL);
139 static void AshikaseSetEnabled(bool enabled, bool always) {
140 if (!Ashikase(always))
143 CFMessagePortSendRequest(ashikase_, MouseMessageTypeSetEnabled, enabled ? cfTrue_ : cfFalse_, 0, 0, NULL, NULL);
146 AshikaseSendEvent(x_, y_);
149 MSClassHook(SBAlertItemsController)
150 MSClassHook(SBStatusBarController)
153 static Class $VNCAlertItem;
155 static rfbNewClientAction action_ = RFB_CLIENT_ON_HOLD;
156 static NSCondition *condition_;
157 static NSLock *lock_;
159 static rfbClientPtr client_;
161 static void VNCSetup();
162 static void VNCEnabled();
164 @interface VNCBridge : NSObject {
167 + (void) askForConnection;
168 + (void) removeStatusBarItem;
169 + (void) registerClient;
173 @implementation VNCBridge
175 + (void) askForConnection {
176 [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$VNCAlertItem alloc] init] autorelease]];
179 + (void) removeStatusBarItem {
180 AshikaseSetEnabled(false, false);
181 [[$SBStatusBarController sharedStatusBarController] removeStatusBarItem:@"Veency"];
184 + (void) registerClient {
185 // XXX: this could find a better home
187 UIScreen *screen([UIScreen mainScreen]);
188 if ([screen respondsToSelector:@selector(scale)])
189 ratio_ = [screen scale];
195 AshikaseSetEnabled(true, false);
196 [[$SBStatusBarController sharedStatusBarController] addStatusBarItem:@"Veency"];
199 + (void) performSetup:(NSThread *)thread {
200 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
201 [thread autorelease];
209 MSInstanceMessage2(void, VNCAlertItem, alertSheet,buttonClicked, id, sheet, int, button) {
214 action_ = RFB_CLIENT_ACCEPT;
216 @synchronized (condition_) {
217 [VNCBridge registerClient];
222 action_ = RFB_CLIENT_REFUSE;
231 MSInstanceMessage2(void, VNCAlertItem, configure,requirePasscodeForActions, BOOL, configure, BOOL, require) {
232 UIModalView *sheet([self alertSheet]);
233 [sheet setDelegate:self];
234 [sheet setTitle:@"Remote Access Request"];
235 [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]];
236 [sheet addButtonWithTitle:@"Accept"];
237 [sheet addButtonWithTitle:@"Reject"];
240 MSInstanceMessage0(void, VNCAlertItem, performUnlockAction) {
241 [[$SBAlertItemsController sharedInstance] activateAlertItem:self];
244 static mach_port_t (*GSTakePurpleSystemEventPort)(void);
245 static bool PurpleAllocated;
248 static void FixRecord(GSEventRecord *record) {
250 memmove(&record->windowContextId, &record->windowContextId + 1, sizeof(*record) - (reinterpret_cast<uint8_t *>(&record->windowContextId + 1) - reinterpret_cast<uint8_t *>(record)) + record->size);
253 static void VNCSettings() {
254 NSDictionary *settings([NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]]);
256 @synchronized (lock_) {
257 for (NSValue *handler in handlers_)
258 rfbUnregisterSecurityHandler(reinterpret_cast<rfbSecurityHandler *>([handler pointerValue]));
259 [handlers_ removeAllObjects];
262 @synchronized (condition_) {
266 [reinterpret_cast<NSString *>(screen_->authPasswdData) release];
267 screen_->authPasswdData = NULL;
270 if (NSString *password = [settings objectForKey:@"Password"])
271 if ([password length] != 0)
272 screen_->authPasswdData = [password retain];
274 NSNumber *cursor = [settings objectForKey:@"ShowCursor"];
275 cursor_ = cursor == nil ? true : [cursor boolValue];
278 AshikaseSetEnabled(cursor_, true);
282 static void VNCNotifySettings(
283 CFNotificationCenterRef center,
292 static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size) {
293 @synchronized (condition_) {
294 if (NSString *password = reinterpret_cast<NSString *>(screen_->authPasswdData)) {
295 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
296 rfbEncryptBytes(client->authChallenge, const_cast<char *>([password UTF8String]));
297 bool good(memcmp(client->authChallenge, data, size) == 0);
306 static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
310 CGPoint location = {x, y};
315 if (width_ > height_) {
317 x = height_ / ratio_ - 1 - y;
327 int diff = buttons_ ^ buttons;
328 bool twas((buttons_ & 0x1) != 0);
329 bool tis((buttons & 0x1) != 0);
332 rfbDefaultPtrAddEvent(buttons, x, y, client);
334 if (Ashikase(false)) {
335 AshikaseSendEvent(x, y, buttons);
339 mach_port_t purple(0);
341 if ((diff & 0x10) != 0) {
342 struct GSEventRecord record;
344 memset(&record, 0, sizeof(record));
346 record.type = (buttons & 0x4) != 0 ?
347 GSEventTypeHeadsetButtonDown :
348 GSEventTypeHeadsetButtonUp;
350 record.timestamp = GSCurrentEventTimestamp();
353 GSSendSystemEvent(&record);
356 if ((diff & 0x04) != 0) {
357 struct GSEventRecord record;
359 memset(&record, 0, sizeof(record));
361 record.type = (buttons & 0x4) != 0 ?
362 GSEventTypeMenuButtonDown :
363 GSEventTypeMenuButtonUp;
365 record.timestamp = GSCurrentEventTimestamp();
368 GSSendSystemEvent(&record);
371 if ((diff & 0x02) != 0) {
372 struct GSEventRecord record;
374 memset(&record, 0, sizeof(record));
376 record.type = (buttons & 0x2) != 0 ?
377 GSEventTypeLockButtonDown :
378 GSEventTypeLockButtonUp;
380 record.timestamp = GSCurrentEventTimestamp();
383 GSSendSystemEvent(&record);
386 if (twas != tis || tis) {
388 struct GSEventRecord record;
390 struct GSEventRecordInfo info;
391 struct GSPathInfo path;
395 memset(&event, 0, sizeof(event));
397 event.record.type = GSEventTypeMouse;
398 event.record.locationInWindow.x = x;
399 event.record.locationInWindow.y = y;
400 event.record.timestamp = GSCurrentEventTimestamp();
401 event.record.size = sizeof(event.data);
403 event.data.info.handInfo.type = twas == tis ?
404 GSMouseEventTypeDragged :
406 GSMouseEventTypeDown :
409 event.data.info.handInfo.x34 = 0x1;
410 event.data.info.handInfo.x38 = tis ? 0x1 : 0x0;
413 event.data.info.pathPositions = 1;
415 event.data.info.x52 = 1;
417 event.data.path.x00 = 0x01;
418 event.data.path.x01 = 0x02;
419 event.data.path.x02 = tis ? 0x03 : 0x00;
420 event.data.path.position = event.record.locationInWindow;
424 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
425 NSArray *displays([server displays]);
426 if (displays != nil && [displays count] != 0)
427 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
428 port = [display clientPortAtPosition:location];
433 purple = (*GSTakePurpleSystemEventPort)();
437 FixRecord(&event.record);
438 GSSendEvent(&event.record, port);
441 if (purple != 0 && PurpleAllocated)
442 mach_port_deallocate(mach_task_self(), purple);
445 GSEventRef (*$GSEventCreateKeyEvent)(int, CGPoint, CFStringRef, CFStringRef, id, UniChar, short, short);
446 GSEventRef (*$GSCreateSyntheticKeyEvent)(UniChar, BOOL, BOOL);
448 static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
453 case XK_Return: key = '\r'; break;
454 case XK_BackSpace: key = 0x7f; break;
460 CGPoint point(CGPointMake(x_, y_));
462 UniChar unicode(key);
463 CFStringRef string(NULL);
465 GSEventRef event0, event1(NULL);
466 if ($GSEventCreateKeyEvent != NULL) {
467 string = CFStringCreateWithCharacters(kCFAllocatorDefault, &unicode, 1);
468 event0 = (*$GSEventCreateKeyEvent)(10, point, string, string, nil, 0, 0, 1);
469 event1 = (*$GSEventCreateKeyEvent)(11, point, string, string, nil, 0, 0, 1);
470 } else if ($GSCreateSyntheticKeyEvent != NULL) {
471 event0 = (*$GSCreateSyntheticKeyEvent)(unicode, YES, YES);
472 GSEventRecord *record(_GSEventGetGSEventRecord(event0));
473 record->type = GSEventTypeKeyDown;
478 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
479 NSArray *displays([server displays]);
480 if (displays != nil && [displays count] != 0)
481 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
482 port = [display clientPortAtPosition:point];
485 mach_port_t purple(0);
489 purple = (*GSTakePurpleSystemEventPort)();
494 GSSendEvent(_GSEventGetGSEventRecord(event0), port);
496 GSSendEvent(_GSEventGetGSEventRecord(event1), port);
499 if (purple != 0 && PurpleAllocated)
500 mach_port_deallocate(mach_task_self(), purple);
509 static void VNCDisconnect(rfbClientPtr client) {
510 @synchronized (condition_) {
512 [VNCBridge performSelectorOnMainThread:@selector(removeStatusBarItem) withObject:nil waitUntilDone:YES];
516 static rfbNewClientAction VNCClient(rfbClientPtr client) {
517 @synchronized (condition_) {
518 if (screen_->authPasswdData != NULL) {
519 [VNCBridge performSelectorOnMainThread:@selector(registerClient) withObject:nil waitUntilDone:YES];
520 client->clientGoneHook = &VNCDisconnect;
521 return RFB_CLIENT_ACCEPT;
527 [VNCBridge performSelectorOnMainThread:@selector(askForConnection) withObject:nil waitUntilDone:NO];
528 while (action_ == RFB_CLIENT_ON_HOLD)
530 rfbNewClientAction action(action_);
531 action_ = RFB_CLIENT_ON_HOLD;
534 if (action == RFB_CLIENT_ACCEPT)
535 client->clientGoneHook = &VNCDisconnect;
539 extern "C" bool GSSystemHasCapability(NSString *);
541 static CFTypeRef (*$GSSystemCopyCapability)(CFStringRef);
542 static CFTypeRef (*$GSSystemGetCapability)(CFStringRef);
544 static void VNCSetup() {
547 @synchronized (condition_) {
549 char *arg0(strdup("VNCServer"));
550 char *argv[] = {arg0, NULL};
551 screen_ = rfbGetScreen(&argc, argv, width_, height_, BitsPerSample, 3, BytesPerPixel);
557 screen_->desktopName = strdup([[[NSProcessInfo processInfo] hostName] UTF8String]);
559 screen_->alwaysShared = TRUE;
560 screen_->handleEventsEagerly = TRUE;
561 screen_->deferUpdateTime = 1000 / 25;
563 screen_->serverFormat.redShift = BitsPerSample * 2;
564 screen_->serverFormat.greenShift = BitsPerSample * 1;
565 screen_->serverFormat.blueShift = BitsPerSample * 0;
567 $GSSystemCopyCapability = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
568 $GSSystemGetCapability = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
572 if ($GSSystemCopyCapability != NULL) {
573 opengles2 = (*$GSSystemCopyCapability)(CFSTR("opengles-2"));
574 } else if ($GSSystemGetCapability != NULL) {
575 opengles2 = (*$GSSystemGetCapability)(CFSTR("opengles-2"));
576 if (opengles2 != NULL)
581 bool accelerated(opengles2 != NULL && [(NSNumber *)opengles2 boolValue]);
584 CoreSurfaceAcceleratorCreate(NULL, NULL, &accelerator_);
586 if (opengles2 != NULL)
587 CFRelease(opengles2);
589 if (accelerator_ != NULL)
590 buffer_ = CoreSurfaceBufferCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:
591 @"PurpleEDRAM", kCoreSurfaceBufferMemoryRegion,
592 [NSNumber numberWithBool:YES], kCoreSurfaceBufferGlobal,
593 [NSNumber numberWithInt:(width_ * BytesPerPixel)], kCoreSurfaceBufferPitch,
594 [NSNumber numberWithInt:width_], kCoreSurfaceBufferWidth,
595 [NSNumber numberWithInt:height_], kCoreSurfaceBufferHeight,
596 [NSNumber numberWithInt:'BGRA'], kCoreSurfaceBufferPixelFormat,
597 [NSNumber numberWithInt:(width_ * height_ * BytesPerPixel)], kCoreSurfaceBufferAllocSize,
602 //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));
604 CoreSurfaceBufferLock(buffer_, 3);
605 screen_->frameBuffer = reinterpret_cast<char *>(CoreSurfaceBufferGetBaseAddress(buffer_));
606 CoreSurfaceBufferUnlock(buffer_);
608 screen_->kbdAddEvent = &VNCKeyboard;
609 screen_->ptrAddEvent = &VNCPointer;
611 screen_->newClientHook = &VNCClient;
612 screen_->passwordCheck = &VNCCheck;
614 screen_->cursor = NULL;
617 static void VNCEnabled() {
621 if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]])
622 if (NSNumber *number = [settings objectForKey:@"Enabled"])
623 enabled = [number boolValue];
625 if (enabled != running_)
628 screen_->socketState = RFB_SOCKET_INIT;
629 rfbInitServer(screen_);
630 rfbRunEventLoop(screen_, -1, true);
632 rfbShutdownServer(screen_, true);
639 static void VNCNotifyEnabled(
640 CFNotificationCenterRef center,
649 void (*$IOMobileFramebufferIsMainDisplay)(IOMobileFramebufferRef, int *);
651 static IOMobileFramebufferRef main_;
652 static CoreSurfaceBufferRef layer_;
654 static void OnLayer(IOMobileFramebufferRef fb, CoreSurfaceBufferRef layer) {
655 if (_unlikely(width_ == 0 || height_ == 0)) {
657 IOMobileFramebufferGetDisplaySize(fb, &size);
660 height_ = size.height;
662 if (width_ == 0 || height_ == 0)
665 NSThread *thread([NSThread alloc]);
668 initWithTarget:[VNCBridge class]
669 selector:@selector(performSetup:)
674 } else if (_unlikely(clients_ != 0)) {
676 if (accelerator_ != NULL)
677 memset(screen_->frameBuffer, 0, sizeof(rfbPixel) * width_ * height_);
681 if (accelerator_ != NULL)
682 CoreSurfaceAcceleratorTransferSurface(accelerator_, layer, buffer_, options_);
684 CoreSurfaceBufferLock(layer, 2);
685 rfbPixel *data(reinterpret_cast<rfbPixel *>(CoreSurfaceBufferGetBaseAddress(layer)));
687 CoreSurfaceBufferFlushProcessorCaches(layer);
689 /*rfbPixel corner(data[0]);
693 screen_->frameBuffer = const_cast<char *>(reinterpret_cast<volatile char *>(data));
694 CoreSurfaceBufferUnlock(layer);
698 rfbMarkRectAsModified(screen_, 0, 0, width_, height_);
702 static bool wait_ = false;
704 MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer,
705 IOMobileFramebufferRef fb,
707 CoreSurfaceBufferRef buffer,
714 if (_unlikely(buffer == NULL))
716 else if (_unlikely(fb == NULL))
718 else if ($IOMobileFramebufferIsMainDisplay == NULL)
721 (*$IOMobileFramebufferIsMainDisplay)(fb, &main);
731 return _IOMobileFramebufferSwapSetLayer(fb, layer, buffer, bounds, frame, flags);
734 // XXX: beg rpetrich for the type of this function
735 extern "C" void *IOMobileFramebufferSwapWait(IOMobileFramebufferRef, void *, unsigned);
737 MSHook(void *, IOMobileFramebufferSwapWait, IOMobileFramebufferRef fb, void *arg1, unsigned flags) {
738 void *value(_IOMobileFramebufferSwapWait(fb, arg1, flags));
744 MSHook(void, rfbRegisterSecurityHandler, rfbSecurityHandler *handler) {
745 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
747 @synchronized (lock_) {
748 [handlers_ addObject:[NSValue valueWithPointer:handler]];
749 _rfbRegisterSecurityHandler(handler);
755 template <typename Type_>
756 static void dlset(Type_ &function, const char *name) {
757 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
761 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
763 MSHookSymbol(GSTakePurpleSystemEventPort, "GSGetPurpleSystemEventPort");
764 if (GSTakePurpleSystemEventPort == NULL) {
765 MSHookSymbol(GSTakePurpleSystemEventPort, "GSCopyPurpleSystemEventPort");
766 PurpleAllocated = true;
769 if (dlsym(RTLD_DEFAULT, "GSLibraryCopyGenerationInfoValueForKey") != NULL)
771 else if (dlsym(RTLD_DEFAULT, "GSKeyboardCreate") != NULL)
773 else if (dlsym(RTLD_DEFAULT, "GSEventGetWindowContextId") != NULL)
779 sysctlbyname("hw.machine", NULL, &size, NULL, 0);
781 sysctlbyname("hw.machine", machine, &size, NULL, 0);
782 iPad1_ = strcmp(machine, "iPad1,1") == 0;
784 dlset($GSEventCreateKeyEvent, "GSEventCreateKeyEvent");
785 dlset($GSCreateSyntheticKeyEvent, "_GSCreateSyntheticKeyEvent");
786 dlset($IOMobileFramebufferIsMainDisplay, "IOMobileFramebufferIsMainDisplay");
788 MSHookFunction(&IOMobileFramebufferSwapSetLayer, MSHake(IOMobileFramebufferSwapSetLayer));
789 MSHookFunction(&rfbRegisterSecurityHandler, MSHake(rfbRegisterSecurityHandler));
792 MSHookFunction(&IOMobileFramebufferSwapWait, MSHake(IOMobileFramebufferSwapWait));
794 $VNCAlertItem = objc_allocateClassPair(objc_getClass("SBAlertItem"), "VNCAlertItem", 0);
795 MSAddMessage2(VNCAlertItem, "v@:@i", alertSheet,buttonClicked);
796 MSAddMessage2(VNCAlertItem, "v@:cc", configure,requirePasscodeForActions);
797 MSAddMessage0(VNCAlertItem, "v@:", performUnlockAction);
798 objc_registerClassPair($VNCAlertItem);
800 CFNotificationCenterAddObserver(
801 CFNotificationCenterGetDarwinNotifyCenter(),
802 NULL, &VNCNotifyEnabled, CFSTR("com.saurik.Veency-Enabled"), NULL, 0
805 CFNotificationCenterAddObserver(
806 CFNotificationCenterGetDarwinNotifyCenter(),
807 NULL, &VNCNotifySettings, CFSTR("com.saurik.Veency-Settings"), NULL, 0
810 condition_ = [[NSCondition alloc] init];
811 lock_ = [[NSLock alloc] init];
812 handlers_ = [[NSMutableSet alloc] init];
817 cfTrue_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
820 cfFalse_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
822 cfEvent_ = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&event_), sizeof(event_), kCFAllocatorNull);
824 options_ = (CFDictionaryRef) [[NSDictionary dictionaryWithObjectsAndKeys: