From 79b78df53f74a3de458e9dc01c35c652d28fd317 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 19 Sep 2008 07:08:47 +0000 Subject: [PATCH] Moved source code of Veency to more obvious location. --- Default_Veency.png | Bin 0 -> 652 bytes FSO_Veency.png | Bin 0 -> 619 bytes Tweak.mm | 196 ++++++++++++++++++++++++++++++++++++--------- control | 15 ++-- makefile | 9 ++- 5 files changed, 176 insertions(+), 44 deletions(-) create mode 100644 Default_Veency.png create mode 100644 FSO_Veency.png diff --git a/Default_Veency.png b/Default_Veency.png new file mode 100644 index 0000000000000000000000000000000000000000..3f93740941a3622356cbc463c30b4722029cd7b0 GIT binary patch literal 652 zcmV;70(1R|P)Px%MoC0LR5;7+Q$a|RVHkeC@BijM|N7VOzm314i#hF(1%E%$Kv=L5C6yQqas(YD z=pfZWigjp*5br{l0uR<9@V*G7d8lC^C@7{7w2Np^AkJUR{mbp`VA+;irw$!@;XQmj z56}0!5AO^7YsCP7dU{+Sszq8`iH(o%0sy5_9P{(iJ|@c*mdTW>>6``z4qhI<9G7gb-W0uIEkD zy!De;(X{u29UY5?Va%$kI;*PctfpyiYsI>|`!fJZ0HLZm=VV#d;9_6jsYxMr@f$8l zl3gpbuppbd?f{^x06mVy?iq$L34r{5|LRhE`^0&Gnwy(9g2CVuAw*gTk(OmSbznqA zQ3wFN28i0)p7-|lUI#$_rY3r)DBn0hrfEK?7Z0y~6pKXwfExhT*ZVD9KMDZJQVCBT zM^pgVw!K3ChY^pTxya(<<#MI&=bW>z*=#ymH*7XE6!%Vrl6iAzTs2{FdR mAFr8Wu>f^-S@>Unt-b@g=gzLm!&w{v0000Px%B}qg9+?igui2LP1)W4ryl zTrOKgRY5hUOW@kkzm2v_= zEEdC=xw+`a?d_#TqmgjATr-_c=i2(l1~g5}8HQnw?uZ}#p6tfSsi{){a8B1ztJM@K zC4>;4#=(^dL|P~my7jtNLpU5pu~>W$;5>la>2$g!g!nO(f@zxT$|RBbr>AvY*Ri^` zhW_qu4!~m~x+H{nGqP;Y*wG}B005uQhb!~*cvr8(>2$u}oZnPc_4~M-QKBG#V8HLc zGraJ6JkLnVU?dXxnayUOB$LV0ob%ui3qao&2@zk+i>&Nbaj`IA1AWsp zFOMCKdA$Ns=3(1arfDAlcqh1L;%}Cg6_7+1@ZbKL{Q}s@=P76rx- #include @@ -13,6 +50,12 @@ #import #import #import +#import +#import + +#import +#import +#import #define IOMobileFramebuffer "/System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer" @@ -31,21 +74,82 @@ static bool running_; static int buttons_; static int x_, y_; -static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) { - x_ = x; - y_ = y; +static unsigned clients_; - int diff = buttons_ ^ buttons; +static Class $VNCAlertItem; +static Class $SBAlertItemsController; +static Class $SBStatusBarController; - rfbDefaultPtrAddEvent(buttons, x, y, client); +static rfbNewClientAction action_ = RFB_CLIENT_ON_HOLD; +static NSCondition *condition_; - mach_port_t purple(0); +static rfbClientPtr client_; + +void VNCAlertItem$alertSheet$buttonClicked$(id self, SEL sel, id sheet, int button) { + [condition_ lock]; + switch (button) { + case 1: + action_ = RFB_CLIENT_ACCEPT; + ++clients_; + [[$SBStatusBarController sharedStatusBarController] addStatusBarItem:@"Veency"]; + break; + + case 2: + action_ = RFB_CLIENT_REFUSE; + break; + } + + [condition_ signal]; + [condition_ unlock]; + [self dismiss]; +} + +void VNCAlertItem$configure$requirePasscodeForActions$(id self, SEL sel, BOOL configure, BOOL require) { + UIModalView *sheet([self alertSheet]); + [sheet setDelegate:self]; + [sheet setTitle:@"Remote Access Request"]; + [sheet setBodyText:[NSString stringWithFormat:@"Accept connection from\n%s?\n\nVeency VNC Server\nby Jay Freeman (saurik)\nsaurik@saurik.com\nhttp://www.saurik.com/", client_->host]]; + [sheet addButtonWithTitle:@"Accept"]; + [sheet addButtonWithTitle:@"Reject"]; +} + +void VNCAlertItem$performUnlockAction(id self, SEL sel) { + [[$SBAlertItemsController sharedInstance] activateAlertItem:self]; +} + +@interface VNCBridge : NSObject { +} + ++ (void) askForConnection; ++ (void) removeStatusBarItem; + +@end + +@implementation VNCBridge + ++ (void) askForConnection { + id item = [[[$VNCAlertItem alloc] init] autorelease]; + [[$SBAlertItemsController sharedInstance] activateAlertItem:item]; +} + ++ (void) removeStatusBarItem { + [[$SBStatusBarController sharedStatusBarController] removeStatusBarItem:@"Veency"]; +} + +@end + +static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) { + x_ = x; y_ = y; + int diff = buttons_ ^ buttons; bool twas((buttons_ & 0x1) != 0); bool tis((buttons & 0x1) != 0); - buttons_ = buttons; + rfbDefaultPtrAddEvent(buttons, x, y, client); + + mach_port_t purple(0); + if ((diff & 0x10) != 0) { struct GSEventRecord record; @@ -60,18 +164,6 @@ static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) { GSSendSystemEvent(&record); } - if ((diff & 0x08) != 0 && (buttons & 0x4) != 0) { - struct GSEventRecord record; - - memset(&record, 0, sizeof(record)); - - record.type = GSEventTypeRingerChanged0; - - record.timestamp = GSCurrentEventTimestamp(); - - GSSendSystemEvent(&record); - } - if ((diff & 0x04) != 0) { struct GSEventRecord record; @@ -193,22 +285,41 @@ static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) { GSSendEvent(&event.record, port); } +static void VNCDisconnect(rfbClientPtr client) { + if (--clients_ == 0) + [VNCBridge performSelectorOnMainThread:@selector(removeStatusBarItem) withObject:nil waitUntilDone:NO]; +} + +static rfbNewClientAction VNCClient(rfbClientPtr client) { + [condition_ lock]; + client_ = client; + [VNCBridge performSelectorOnMainThread:@selector(askForConnection) withObject:nil waitUntilDone:NO]; + while (action_ == RFB_CLIENT_ON_HOLD) + [condition_ wait]; + rfbNewClientAction action(action_); + action_ = RFB_CLIENT_ON_HOLD; + [condition_ unlock]; + if (action == RFB_CLIENT_ACCEPT) + client->clientGoneHook = &VNCDisconnect; + return action; +} + +static rfbPixel black_[320][480]; + static void *VNCServer(IOMobileFramebufferRef fb) { CGRect rect(CGRectMake(0, 0, Width, Height)); - CoreSurfaceBufferRef surface(NULL); + /*CoreSurfaceBufferRef surface(NULL); kern_return_t value(IOMobileFramebufferGetLayerDefaultSurface(fb, 0, &surface)); if (value != 0) - return NULL; + return NULL;*/ + + condition_ = [[NSCondition alloc] init]; int argc(1); char *arg0(strdup("VNCServer")); char *argv[] = {arg0, NULL}; - io_service_t service(IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOCoreSurfaceRoot"))); - CFMutableDictionaryRef properties(NULL); - IORegistryEntryCreateCFProperties(service, &properties, kCFAllocatorDefault, kNilOptions); - screen_ = rfbGetScreen(&argc, argv, Width, Height, BitsPerSample, 3, BytesPerPixel); screen_->desktopName = "iPhone"; screen_->alwaysShared = TRUE; @@ -219,13 +330,26 @@ static void *VNCServer(IOMobileFramebufferRef fb) { screen_->serverFormat.greenShift = BitsPerSample * 1; screen_->serverFormat.blueShift = BitsPerSample * 0; + /*io_service_t service(IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOCoreSurfaceRoot"))); + CFMutableDictionaryRef properties(NULL); + IORegistryEntryCreateCFProperties(service, &properties, kCFAllocatorDefault, kNilOptions); + CoreSurfaceBufferLock(surface, kCoreSurfaceLockTypeGimmeVRAM); screen_->frameBuffer = reinterpret_cast(CoreSurfaceBufferGetBaseAddress(surface)); CoreSurfaceBufferUnlock(surface); + CFRelease(surface);*/ + + screen_->frameBuffer = reinterpret_cast(black_); screen_->kbdAddEvent = &VNCKeyboard; screen_->ptrAddEvent = &VNCPointer; + screen_->newClientHook = &VNCClient; + + /*char data[0], mask[0]; + rfbCursorPtr cursor = rfbMakeXCursor(0, 0, data, mask); + rfbSetCursor(screen_, cursor);*/ + rfbInitServer(screen_); running_ = true; @@ -235,14 +359,10 @@ static void *VNCServer(IOMobileFramebufferRef fb) { running_ = false; rfbScreenCleanup(screen_); - CFRelease(surface); - free(arg0); return NULL; } -static rfbPixel black_[320][480]; - MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer, IOMobileFramebufferRef fb, int layer, @@ -263,12 +383,9 @@ MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer, if (buffer == NULL) screen_->frameBuffer = reinterpret_cast(black_); else { - CoreSurfaceBufferLock(buffer, kCoreSurfaceLockTypeGimmeVRAM); + CoreSurfaceBufferLock(buffer, 2); rfbPixel (*data)[480] = reinterpret_cast(CoreSurfaceBufferGetBaseAddress(buffer)); - /*memcpy(black_, data, sizeof(black_)); - screen_->frameBuffer = reinterpret_cast(black_);*/ - data[x_][y_] = screen_->whitePixel; - screen_->frameBuffer = reinterpret_cast(data); + screen_->frameBuffer = const_cast(reinterpret_cast(data)); CoreSurfaceBufferUnlock(buffer); } } @@ -284,7 +401,14 @@ MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer, } extern "C" void TweakInitialize() { - if (objc_getClass("SpringBoard") == nil) - return; MSHookFunction(&IOMobileFramebufferSwapSetLayer, &$IOMobileFramebufferSwapSetLayer, &_IOMobileFramebufferSwapSetLayer); + + $SBAlertItemsController = objc_getClass("SBAlertItemsController"); + $SBStatusBarController = objc_getClass("SBStatusBarController"); + + $VNCAlertItem = objc_allocateClassPair(objc_getClass("SBAlertItem"), "VNCAlertItem", 0); + class_addMethod($VNCAlertItem, @selector(alertSheet:buttonClicked:), (IMP) &VNCAlertItem$alertSheet$buttonClicked$, "v@:@i"); + class_addMethod($VNCAlertItem, @selector(configure:requirePasscodeForActions:), (IMP) &VNCAlertItem$configure$requirePasscodeForActions$, "v@:cc"); + class_addMethod($VNCAlertItem, @selector(performUnlockAction), (IMP) VNCAlertItem$performUnlockAction, "v@:"); + objc_registerClassPair($VNCAlertItem); } diff --git a/control b/control index 5b68b9e..b818cf5 100644 --- a/control +++ b/control @@ -1,11 +1,14 @@ -Package: com.saurik.iphone.vncs +Package: veency +Conflicts: com.saurik.iphone.vncs +Replaces: com.saurik.iphone.vncs Priority: optional -Section: Tweaks +Section: Networking Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.2587-1 -Description: remotely watch your iPhone screen -Name: VNC Server +Version: 0.9.2591-1 +Description: a VNC /server/ for the iPhone +Name: Veency Depends: mobilesubstrate (>= 0.9.2587-1), libvncserver Author: Jay Freeman (saurik) -Depiction: http://cydia.saurik.com/info/com.saurik.iphone.vncs/ +Depiction: http://cydia.saurik.com/info/veency/ +Tag: purpose::daemon, role::enduser diff --git a/makefile b/makefile index 65a625b..3f0ac4b 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,9 @@ -name := VNCServer +name := Veency id := vncs flags := -lvncserver -framework IOMobileFramebuffer -framework CoreSurface -framework IOKit -framework GraphicsServices -I/apl/inc/iPhoneOS-2.0 -framework QuartzCore -include ../tweak.mk +base := ../tweaks +include ../tweaks/tweak.mk + +extra: + mkdir -p package/System/Library/CoreServices/SpringBoard.app + cp -a Default_Veency.png FSO_Veency.png package/System/Library/CoreServices/SpringBoard.app -- 2.45.2