]> git.saurik.com Git - veency.git/commitdiff
Moved source code of Veency to more obvious location. v0.9.2591
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 19 Sep 2008 07:08:47 +0000 (07:08 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 19 Sep 2008 07:08:47 +0000 (07:08 +0000)
Default_Veency.png [new file with mode: 0644]
FSO_Veency.png [new file with mode: 0644]
Tweak.mm
control
makefile

diff --git a/Default_Veency.png b/Default_Veency.png
new file mode 100644 (file)
index 0000000..3f93740
Binary files /dev/null and b/Default_Veency.png differ
diff --git a/FSO_Veency.png b/FSO_Veency.png
new file mode 100644 (file)
index 0000000..c1a628b
Binary files /dev/null and b/FSO_Veency.png differ
index f67c02cd04f552be26c6d24ba6c875b1c25f92fe..f1f7b83bc4e695e31339afe8e0ecc9c0fbc88d79 100644 (file)
--- a/Tweak.mm
+++ b/Tweak.mm
@@ -1,3 +1,40 @@
+/* Veency - VNC Remote Access Server for iPhoneOS
+ * Copyright (C) 2008  Jay Freeman (saurik)
+*/
+
+/*
+ *        Redistribution and use in source and binary
+ * forms, with or without modification, are permitted
+ * provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the
+ *    above copyright notice, this list of conditions
+ *    and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the
+ *    above copyright notice, this list of conditions
+ *    and the following disclaimer in the documentation
+ *    and/or other materials provided with the
+ *    distribution.
+ * 3. The name of the author may not be used to endorse
+ *    or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
 #include <substrate.h>
 
 #include <rfb/rfb.h>
 #import <Foundation/Foundation.h>
 #import <IOMobileFramebuffer/IOMobileFramebuffer.h>
 #import <IOKit/IOKitLib.h>
+#import <UIKit/UIModalView.h>
+#import <UIKit/UIModalView-Private.h>
+
+#import <SpringBoard/SBAlertItemsController.h>
+#import <SpringBoard/SBDismissOnlyAlertItem.h>
+#import <SpringBoard/SBStatusBarController.h>
 
 #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<char *>(CoreSurfaceBufferGetBaseAddress(surface));
     CoreSurfaceBufferUnlock(surface);
+    CFRelease(surface);*/
+
+    screen_->frameBuffer = reinterpret_cast<char *>(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<char *>(black_);
         else {
-            CoreSurfaceBufferLock(buffer, kCoreSurfaceLockTypeGimmeVRAM);
+            CoreSurfaceBufferLock(buffer, 2);
             rfbPixel (*data)[480] = reinterpret_cast<rfbPixel (*)[480]>(CoreSurfaceBufferGetBaseAddress(buffer));
-            /*memcpy(black_, data, sizeof(black_));
-            screen_->frameBuffer = reinterpret_cast<char *>(black_);*/
-            data[x_][y_] = screen_->whitePixel;
-            screen_->frameBuffer = reinterpret_cast<char *>(data);
+            screen_->frameBuffer = const_cast<char *>(reinterpret_cast<volatile char *>(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 5b68b9e727ae47bc7f0c1a7941722442330033bb..b818cf5e5e3f94669a97d40a245d168982b2b634 100644 (file)
--- 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) <saurik@saurik.com>
 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) <saurik@saurik.com>
-Depiction: http://cydia.saurik.com/info/com.saurik.iphone.vncs/
+Depiction: http://cydia.saurik.com/info/veency/
+Tag: purpose::daemon, role::enduser
index 65a625b746f83ad2b6d26973f1843dbc0197b1cb..3f0ac4b88c8870c7a91f0cc4388590253c165769 100644 (file)
--- 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