]> git.saurik.com Git - cydget.git/commitdiff
Merged WebCycript into the core cydgets distribution.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 5 Nov 2009 22:07:24 +0000 (22:07 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 5 Nov 2009 22:07:24 +0000 (22:07 +0000)
CydgetCentral.plist [new file with mode: 0644]
Info.plist [new file with mode: 0644]
LockScreen.mk
LockScreen.mm [new file with mode: 0644]
makefile
webcycript/CydgetCentral.plist [deleted file]
webcycript/Info.plist [deleted file]
webcycript/LockScreen.mm [deleted file]
webcycript/control [deleted file]
webcycript/make.sh [deleted file]
webcycript/makefile [deleted file]

diff --git a/CydgetCentral.plist b/CydgetCentral.plist
new file mode 100644 (file)
index 0000000..c96cf0f
--- /dev/null
@@ -0,0 +1,4 @@
+Plugin = "WebCycriptLockScreen";
+Configuration = {
+    Homepage = "http://www.cydget.org/central/";
+};
diff --git a/Info.plist b/Info.plist
new file mode 100644 (file)
index 0000000..c4be864
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+        <key>CFBundleDevelopmentRegion</key>
+        <string>English</string>
+        <key>CFBundleExecutable</key>
+        <string>WebCycriptLockScreen</string>
+        <key>CFBundleIdentifier</key>
+        <string>com.saurik.WebCycriptLockScreen</string>
+        <key>CFBundleInfoDictionaryVersion</key>
+        <string>6.0</string>
+        <key>CFBundlePackageType</key>
+        <string>BNDL</string>
+        <key>CFBundleSignature</key>
+        <string>????</string>
+        <key>CFBundleVersion</key>
+        <string>1.0</string>
+        <key>DTPlatformName</key>
+        <string>iphoneos</string>
+        <key>MinimumOSVersion</key>
+        <string>2.1</string>
+        <key>NSPrincipalClass</key>
+        <string>WebCycriptLockScreenController</string>
+</dict>
+</plist>
index b54d6da6b699eff8ebfae9e94b1c77fc20ee5a06..87e5791b2178e47fa6eea7dc1f1e74162a28d3c1 100644 (file)
@@ -31,6 +31,7 @@ $(deb): $(name)LockScreen
        mkdir -p package/System/Library/SpringBoardPlugins/$(name)LockScreen.bundle
        cp -a Info.plist package/System/Library/SpringBoardPlugins/$(name)LockScreen.bundle
        cp -a $(name)LockScreen package/System/Library/SpringBoardPlugins/$(name)LockScreen.bundle
+       $(MAKE) extra
        dpkg-deb -b package $(deb)
 
 extra:
diff --git a/LockScreen.mm b/LockScreen.mm
new file mode 100644 (file)
index 0000000..f919b52
--- /dev/null
@@ -0,0 +1,703 @@
+/* CydgetScript - open-source IntelliDial replacement
+ * Copyright (C) 2009  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>
+
+#import <GraphicsServices/GraphicsServices.h>
+#import <UIKit/UIKit.h>
+#import <AddressBook/AddressBook.h>
+
+#import <SpringBoardUI/SBAwayViewPluginController.h>
+
+#import <QuartzCore/CALayer.h>
+// XXX: fix the minimum requirement
+extern NSString * const kCAFilterNearest;
+
+#include <WebKit/DOMCSSPrimitiveValue.h>
+#include <WebKit/DOMCSSStyleDeclaration.h>
+#include <WebKit/DOMDocument.h>
+#include <WebKit/DOMHTMLBodyElement.h>
+#include <WebKit/DOMNodeList.h>
+#include <WebKit/DOMRGBColor.h>
+
+#include <WebKit/WebFrame.h>
+#include <WebKit/WebPolicyDelegate.h>
+#include <WebKit/WebPreferences.h>
+#include <WebKit/WebScriptObject.h>
+
+#import <WebKit/WebView.h>
+#import <WebKit/WebView-WebPrivate.h>
+
+#include <WebCore/Page.h>
+#include <WebCore/Settings.h>
+
+#include <WebCore/WebCoreThread.h>
+#include <WebKit/WebPreferences-WebPrivate.h>
+
+@interface WebView (UICaboodle)
+- (void) setScriptDebugDelegate:(id)delegate;
+- (void) _setFormDelegate:(id)delegate;
+- (void) _setUIKitDelegate:(id)delegate;
+- (void) setWebMailDelegate:(id)delegate;
+- (void) _setLayoutInterval:(float)interval;
+@end
+
+#define _transient
+#define _forever for (;;)
+
+_disused static unsigned trace_;
+
+#define _trace() do { \
+    NSLog(@"_trace(%u)@%s:%u[%s]\n", \
+        trace_++, __FILE__, __LINE__, __FUNCTION__\
+    ); \
+} while (false)
+
+@protocol CydgetController
+- (NSDictionary *) currentConfiguration;
+@end
+
+static Class $CydgetController(objc_getClass("CydgetController"));
+
+@interface NSString (UIKit)
+- (NSString *) stringByAddingPercentEscapes;
+@end
+
+@implementation UIWebDocumentView (WebCycript)
+
+- (void) _setScrollerOffset:(CGPoint)offset {
+    UIScroller *scroller([self _scroller]);
+
+    CGSize size([scroller contentSize]);
+    CGSize bounds([scroller bounds].size);
+
+    CGPoint max;
+    max.x = size.width - bounds.width;
+    max.y = size.height - bounds.height;
+
+    // wtf Apple?!
+    if (max.x < 0)
+        max.x = 0;
+    if (max.y < 0)
+        max.y = 0;
+
+    offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
+    offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
+
+    [scroller setOffset:offset];
+}
+
+@end
+
+/* WebCycript Delegate {{{ */
+@interface WebCycriptDelegate : NSObject {
+    _transient volatile id delegate_;
+}
+
+- (void) setDelegate:(id)delegate;
+- (id) initWithDelegate:(id)delegate;
+@end
+
+@implementation WebCycriptDelegate
+
+- (void) setDelegate:(id)delegate {
+    delegate_ = delegate;
+}
+
+- (id) initWithDelegate:(id)delegate {
+    delegate_ = delegate;
+    return self;
+}
+
+- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender didClearWindowObject:window forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender didCommitLoadForFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender didFailLoadWithError:error forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender didFinishLoadForFrame:frame];
+}
+
+/*- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender didReceiveTitle:title forFrame:frame];
+}*/
+
+- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender didStartProvisionalLoadForFrame:frame];
+}
+
+/*- (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
+}*/
+
+/*- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
+    if (delegate_ != nil)
+        return [delegate_ webView:sender resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:source];
+    return nil;
+}*/
+
+- (IMP) methodForSelector:(SEL)sel {
+    if (IMP method = [super methodForSelector:sel])
+        return method;
+    fprintf(stderr, "methodForSelector:[%s] == NULL\n", sel_getName(sel));
+    return NULL;
+}
+
+- (BOOL) respondsToSelector:(SEL)sel {
+    if ([super respondsToSelector:sel])
+        return YES;
+    // XXX: WebThreadCreateNSInvocation returns nil
+    //fprintf(stderr, "[%s]R?%s\n", class_getName(self->isa), sel_getName(sel));
+    return delegate_ == nil ? NO : [delegate_ respondsToSelector:sel];
+}
+
+- (NSMethodSignature *) methodSignatureForSelector:(SEL)sel {
+    if (NSMethodSignature *method = [super methodSignatureForSelector:sel])
+        return method;
+    //fprintf(stderr, "[%s]S?%s\n", class_getName(self->isa), sel_getName(sel));
+    if (delegate_ != nil)
+        if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel])
+            return sig;
+    // XXX: I fucking hate Apple so very very bad
+    return [NSMethodSignature signatureWithObjCTypes:"v@:"];
+}
+
+- (void) forwardInvocation:(NSInvocation *)inv {
+    SEL sel = [inv selector];
+    if (delegate_ != nil && [delegate_ respondsToSelector:sel])
+        [inv invokeWithTarget:delegate_];
+}
+
+@end
+/* }}} */
+
+@interface WebCydgetLockScreenView : UIView {
+    WebCycriptDelegate *indirect_;
+    UIProgressIndicator *indicator_;
+    UIScroller *scroller_;
+    UIWebDocumentView *document_;
+
+    float width_;
+    CGSize size_;
+    bool editing_;
+
+    NSNumber *confirm_;
+
+    NSMutableSet *loading_;
+    bool error_;
+    bool reloading_;
+}
+
+@end
+
+@implementation WebCydgetLockScreenView
+
+//#include "UICaboodle/UCInternal.h"
+
+- (void) dealloc {
+_trace();
+    WebThreadLock();
+
+    WebView *webview([document_ webView]);
+    [webview setFrameLoadDelegate:nil];
+    [webview setResourceLoadDelegate:nil];
+    [webview setUIDelegate:nil];
+    [webview setScriptDebugDelegate:nil];
+    [webview setPolicyDelegate:nil];
+
+    /* XXX: these are set by UIWebDocumentView
+    [webview setDownloadDelegate:nil];
+    [webview _setFormDelegate:nil];
+    [webview _setUIKitDelegate:nil];
+    [webview setEditingDelegate:nil];*/
+
+    /* XXX: no one sets this, ever
+    [webview setWebMailDelegate:nil];*/
+
+    [document_ setDelegate:nil];
+    [document_ setGestureDelegate:nil];
+    [document_ setFormEditingDelegate:nil];
+    [document_ setInteractionDelegate:nil];
+
+    [indirect_ setDelegate:nil];
+
+    [webview close];
+    [document_ release];
+
+    [indirect_ release];
+
+    WebThreadUnlock();
+
+    [scroller_ setDelegate:nil];
+
+    if (confirm_ != nil)
+        [confirm_ release];
+
+    [scroller_ release];
+    [indicator_ release];
+    [super dealloc];
+}
+
++ (float) defaultWidth {
+    return 980;
+}
+
+- (void) _setTileDrawingEnabled:(BOOL)enabled {
+    //[document_ setTileDrawingEnabled:enabled];
+}
+
+- (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
+    [self _setTileDrawingEnabled:NO];
+}
+
+- (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
+    [self _setTileDrawingEnabled:YES];
+    [document_ redrawScaledDocument];
+}
+
+- (void) setViewportWidth:(float)width {
+    width_ = width != 0 ? width : [[self class] defaultWidth];
+    [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+}
+
+- (void) scrollerWillStartDragging:(UIScroller *)scroller {
+    [self _setTileDrawingEnabled:NO];
+}
+
+- (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
+    [self _setTileDrawingEnabled:YES];
+}
+
+- (void) scrollerDidEndDragging:(UIScroller *)scroller {
+    [self _setTileDrawingEnabled:YES];
+}
+
+- (void) loadRequest:(NSURLRequest *)request {
+    error_ = false;
+
+    WebThreadLock();
+    [document_ loadRequest:request];
+    WebThreadUnlock();
+}
+
+- (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
+    [self loadRequest:[NSURLRequest
+        requestWithURL:url
+        cachePolicy:policy
+        timeoutInterval:30.0
+    ]];
+}
+
+- (void) loadURL:(NSURL *)url {
+    [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
+}
+
+- (id) init {
+    CGRect frame = {{0, 0}, {320, 480}};
+    frame.size.height -= GSDefaultStatusBarHeight();
+
+    if ((self = [super initWithFrame:frame]) != nil) {
+        struct CGRect bounds([self bounds]);
+
+        scroller_ = [[UIScroller alloc] initWithFrame:bounds];
+        [self addSubview:scroller_];
+
+        [scroller_ setFixedBackgroundPattern:YES];
+        [scroller_ setBackgroundColor:[UIColor blackColor]];
+
+        [scroller_ setScrollingEnabled:YES];
+        [scroller_ setClipsSubviews:YES];
+        [scroller_ setAllowsRubberBanding:YES];
+
+        [scroller_ setDelegate:self];
+        [scroller_ setBounces:YES];
+        [scroller_ setScrollHysteresis:8];
+        [scroller_ setThumbDetectionEnabled:NO];
+        [scroller_ setDirectionalScrolling:YES];
+        [scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
+        [scroller_ setEventMode:YES];
+        [scroller_ setShowBackgroundShadow:NO]; /* YES */
+        [scroller_ setAllowsRubberBanding:YES]; /* Vertical */
+        [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
+
+        CGRect rect([scroller_ bounds]);
+        //rect.size.height = 0;
+
+        WebThreadLock();
+
+        document_ = [[UIWebDocumentView alloc] initWithFrame:rect];
+        WebView *webview([document_ webView]);
+
+        [document_ setBackgroundColor:[UIColor blackColor]];
+        if ([document_ respondsToSelector:@selector(setDrawsBackground:)])
+            [document_ setDrawsBackground:NO];
+        [webview setDrawsBackground:NO];
+
+        [webview setPreferencesIdentifier:@"WebCycript"];
+
+        [document_ setTileSize:CGSizeMake(rect.size.width, 500)];
+
+        if ([document_ respondsToSelector:@selector(enableReachability)])
+            [document_ enableReachability];
+
+        [document_ setAllowsMessaging:YES];
+
+        if ([document_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
+            [document_ useSelectionAssistantWithMode:0];
+
+        [document_ setTilingEnabled:YES];
+        [document_ setDrawsGrid:NO];
+        [document_ setLogsTilingChanges:NO];
+        [document_ setTileMinificationFilter:kCAFilterNearest];
+
+        if ([document_ respondsToSelector:@selector(setDataDetectorTypes:)])
+            /* XXX: abstractify */
+            [document_ setDataDetectorTypes:0x80000000];
+        else
+            [document_ setDetectsPhoneNumbers:NO];
+
+        [document_ setAutoresizes:YES];
+
+        [document_ setMinimumScale:0.25f forDocumentTypes:0x10];
+        [document_ setMaximumScale:5.00f forDocumentTypes:0x10];
+        [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
+        //[document_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+
+        [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
+
+        [document_ setMinimumScale:1.00f forDocumentTypes:0x8];
+        [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
+        [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
+
+        [document_ _setDocumentType:0x4];
+
+        if ([document_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
+            [document_ setZoomsFocusedFormControl:YES];
+        [document_ setContentsPosition:7];
+        [document_ setEnabledGestures:0xa];
+        [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
+        [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
+
+        [document_ setSmoothsFonts:YES];
+        [document_ setAllowsImageSheet:YES];
+        [webview _setUsesLoaderCache:YES];
+
+        [webview setGroupName:@"CydgetGroup"];
+
+        WebPreferences *preferences([webview preferences]);
+
+        if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
+            [webview _setLayoutInterval:0];
+        else
+            [preferences _setLayoutInterval:0];
+
+        [self setViewportWidth:0];
+
+        [document_ setDelegate:self];
+        [document_ setGestureDelegate:self];
+        [document_ setFormEditingDelegate:self];
+        [document_ setInteractionDelegate:self];
+
+        [scroller_ addSubview:document_];
+
+        //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+
+        indirect_ = [[WebCycriptDelegate alloc] initWithDelegate:self];
+
+        [webview setFrameLoadDelegate:indirect_];
+        [webview setPolicyDelegate:indirect_];
+        [webview setResourceLoadDelegate:indirect_];
+        [webview setUIDelegate:indirect_];
+
+        /* XXX: do not turn this on under penalty of extreme pain */
+        [webview setScriptDebugDelegate:nil];
+
+        WebThreadUnlock();
+
+        CGSize indsize([UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite]);
+        indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 12, indsize.width, indsize.height)];
+        [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
+
+        [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
+        [scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
+
+        NSDictionary *configuration([$CydgetController currentConfiguration]);
+        NSString *homepage([configuration objectForKey:@"Homepage"]);
+        [self loadURL:[NSURL URLWithString:homepage]];
+    } return self;
+}
+
+- (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+    [self retain];
+
+    UIActionSheet *sheet = [[[UIActionSheet alloc]
+        initWithTitle:nil
+        buttons:[NSArray arrayWithObjects:@"OK", nil]
+        defaultButtonIndex:0
+        delegate:self
+        context:@"alert"
+    ] autorelease];
+
+    [sheet setBodyText:message];
+    [sheet popupAlertAnimated:YES];
+}
+
+- (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+    [self retain];
+
+    UIActionSheet *sheet = [[[UIActionSheet alloc]
+        initWithTitle:nil
+        buttons:[NSArray arrayWithObjects:@"OK", @"CANCEL", nil]
+        defaultButtonIndex:0
+        delegate:indirect_
+        context:@"confirm"
+    ] autorelease];
+
+    [sheet setNumberOfRows:1];
+    [sheet setBodyText:message];
+    [sheet popupAlertAnimated:YES];
+
+    NSRunLoop *loop([NSRunLoop currentRunLoop]);
+    NSDate *future([NSDate distantFuture]);
+
+    while (confirm_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
+
+    NSNumber *confirm([confirm_ autorelease]);
+    confirm_ = nil;
+
+    [self autorelease];
+    return [confirm boolValue];
+}
+
+/* XXX: WebThreadLock? */
+- (void) _fixScroller:(CGRect)bounds {
+    float extra;
+    if (!editing_)
+        extra = 0;
+    else {
+        UIFormAssistant *assistant([UIFormAssistant sharedFormAssistant]);
+        CGRect peripheral([assistant peripheralFrame]);
+        extra = peripheral.size.height;
+    }
+
+    CGRect subrect([scroller_ frame]);
+    subrect.size.height -= extra;
+    [scroller_ setScrollerIndicatorSubrect:subrect];
+
+    NSSize visible(NSMakeSize(subrect.size.width, subrect.size.height));
+    [document_ setValue:[NSValue valueWithSize:visible] forGestureAttribute:UIGestureAttributeVisibleSize];
+
+    CGSize size(size_);
+    size.height += extra;
+    [scroller_ setContentSize:size];
+
+    [scroller_ releaseRubberBandIfNecessary];
+}
+
+- (void) fixScroller {
+    CGRect bounds([document_ documentBounds]);
+    [self _fixScroller:bounds];
+}
+
+- (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
+    size_ = frame.size;
+    [self _fixScroller:frame];
+}
+
+- (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
+    [self view:sender didSetFrame:frame];
+}
+
+- (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
+    editing_ = true;
+}
+
+- (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
+    [self fixScroller];
+}
+
+- (void) webViewDidEndEditingFormElements:(WebView *)sender {
+    editing_ = false;
+    [self fixScroller];
+}
+
+- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+}
+
+- (bool) isLoading {
+    return [loading_ count] != 0;
+}
+
+- (void) reloadButtons {
+    if ([self isLoading])
+        [indicator_ startAnimation];
+    else
+        [indicator_ stopAnimation];
+}
+
+- (void) _finishLoading {
+    size_t count([loading_ count]);
+    /*if (count == 0)
+        [self autorelease];*/
+    if (reloading_ || count != 0)
+        return;
+    [self reloadButtons];
+}
+
+- (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
+    return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
+    return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
+    return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
+    return [document_ webView:sender didCommitLoadForFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
+    return [document_ webView:sender didReceiveDocTypeForFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
+    [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
+    [self _finishLoading];
+    return [document_ webView:sender didFinishLoadForFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
+    /*if ([loading_ count] == 0)
+        [self retain];*/
+    [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
+
+    if ([frame parentFrame] == nil) {
+        [document_ resignFirstResponder];
+
+        reloading_ = false;
+
+        [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
+
+        if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
+            [scroller_ setZoomScale:1 duration:0];
+        else if ([scroller_ respondsToSelector:@selector(_setZoomScale:duration:)])
+            [scroller_ _setZoomScale:1 duration:0];
+        /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
+            [scroller_ setZoomScale:1 animated:NO];*/
+
+        CGRect rect([scroller_ bounds]);
+        //rect.size.height = 0;
+        [document_ setFrame:rect];
+    }
+
+    [self reloadButtons];
+}
+
+- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
+    _trace();
+    /*if ([frame parentFrame] == nil)
+        [self autorelease];*/
+
+    [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
+    [self _finishLoading];
+
+    if (reloading_)
+        return;
+
+    if ([frame parentFrame] == nil) {
+        [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
+            [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
+            [[error localizedDescription] stringByAddingPercentEscapes]
+        ]]];
+
+        error_ = true;
+    }
+}
+
+- (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+    [self _didFailWithError:error forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+    [self _didFailWithError:error forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
+    fprintf(stderr, "Console:%s\n", [[dictionary description] UTF8String]);
+}
+
+@end
+
+@interface WebCycriptLockScreenController : SBAwayViewPluginController {
+}
+
+@end
+
+@implementation WebCycriptLockScreenController
+
++ (id) rootViewController {
+    return [[[self alloc] init] autorelease];
+}
+
+- (void) loadView {
+    [self setView:[[[WebCydgetLockScreenView alloc] init] autorelease]];
+}
+
+@end
index 63fd4b1d242f60458c58c386a8db413a436bb639..9782796caa25c35fc7285ea721b27f7532193325 100644 (file)
--- a/makefile
+++ b/makefile
@@ -3,5 +3,15 @@ flags := -framework UIKit -framework AddressBook
 base := $(shell cd ~; pwd)/menes/tweaks
 include $(base)/tweak.mk
 
+all: WebCycriptLockScreen
+
+WebCycriptLockScreen: LockScreen.mm makefile $(base)/../mobilesubstrate/substrate.h
+       $(target)g++ -bundle -mthumb -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -lobjc -I$(base)/../mobilesubstrate $(link) $(flags) -framework CoreGraphics -framework QuartzCore -framework SpringBoardUI -framework WebCore -framework GraphicsServices
+       ldid -S $@
+
 extra:
-       mkdir -p package/System/Library/LockCydgets
+       mkdir -p package/System/Library/LockCydgets/CydgetCentral.cydget
+       cp -a CydgetCentral.plist package/System/Library/LockCydgets/CydgetCentral.cydget/Info.plist
+       mkdir -p package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
+       cp -a Info.plist package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
+       cp -a WebCycriptLockScreen package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
diff --git a/webcycript/CydgetCentral.plist b/webcycript/CydgetCentral.plist
deleted file mode 100644 (file)
index c96cf0f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Plugin = "WebCycriptLockScreen";
-Configuration = {
-    Homepage = "http://www.cydget.org/central/";
-};
diff --git a/webcycript/Info.plist b/webcycript/Info.plist
deleted file mode 100644 (file)
index c4be864..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-        <key>CFBundleDevelopmentRegion</key>
-        <string>English</string>
-        <key>CFBundleExecutable</key>
-        <string>WebCycriptLockScreen</string>
-        <key>CFBundleIdentifier</key>
-        <string>com.saurik.WebCycriptLockScreen</string>
-        <key>CFBundleInfoDictionaryVersion</key>
-        <string>6.0</string>
-        <key>CFBundlePackageType</key>
-        <string>BNDL</string>
-        <key>CFBundleSignature</key>
-        <string>????</string>
-        <key>CFBundleVersion</key>
-        <string>1.0</string>
-        <key>DTPlatformName</key>
-        <string>iphoneos</string>
-        <key>MinimumOSVersion</key>
-        <string>2.1</string>
-        <key>NSPrincipalClass</key>
-        <string>WebCycriptLockScreenController</string>
-</dict>
-</plist>
diff --git a/webcycript/LockScreen.mm b/webcycript/LockScreen.mm
deleted file mode 100644 (file)
index f919b52..0000000
+++ /dev/null
@@ -1,703 +0,0 @@
-/* CydgetScript - open-source IntelliDial replacement
- * Copyright (C) 2009  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>
-
-#import <GraphicsServices/GraphicsServices.h>
-#import <UIKit/UIKit.h>
-#import <AddressBook/AddressBook.h>
-
-#import <SpringBoardUI/SBAwayViewPluginController.h>
-
-#import <QuartzCore/CALayer.h>
-// XXX: fix the minimum requirement
-extern NSString * const kCAFilterNearest;
-
-#include <WebKit/DOMCSSPrimitiveValue.h>
-#include <WebKit/DOMCSSStyleDeclaration.h>
-#include <WebKit/DOMDocument.h>
-#include <WebKit/DOMHTMLBodyElement.h>
-#include <WebKit/DOMNodeList.h>
-#include <WebKit/DOMRGBColor.h>
-
-#include <WebKit/WebFrame.h>
-#include <WebKit/WebPolicyDelegate.h>
-#include <WebKit/WebPreferences.h>
-#include <WebKit/WebScriptObject.h>
-
-#import <WebKit/WebView.h>
-#import <WebKit/WebView-WebPrivate.h>
-
-#include <WebCore/Page.h>
-#include <WebCore/Settings.h>
-
-#include <WebCore/WebCoreThread.h>
-#include <WebKit/WebPreferences-WebPrivate.h>
-
-@interface WebView (UICaboodle)
-- (void) setScriptDebugDelegate:(id)delegate;
-- (void) _setFormDelegate:(id)delegate;
-- (void) _setUIKitDelegate:(id)delegate;
-- (void) setWebMailDelegate:(id)delegate;
-- (void) _setLayoutInterval:(float)interval;
-@end
-
-#define _transient
-#define _forever for (;;)
-
-_disused static unsigned trace_;
-
-#define _trace() do { \
-    NSLog(@"_trace(%u)@%s:%u[%s]\n", \
-        trace_++, __FILE__, __LINE__, __FUNCTION__\
-    ); \
-} while (false)
-
-@protocol CydgetController
-- (NSDictionary *) currentConfiguration;
-@end
-
-static Class $CydgetController(objc_getClass("CydgetController"));
-
-@interface NSString (UIKit)
-- (NSString *) stringByAddingPercentEscapes;
-@end
-
-@implementation UIWebDocumentView (WebCycript)
-
-- (void) _setScrollerOffset:(CGPoint)offset {
-    UIScroller *scroller([self _scroller]);
-
-    CGSize size([scroller contentSize]);
-    CGSize bounds([scroller bounds].size);
-
-    CGPoint max;
-    max.x = size.width - bounds.width;
-    max.y = size.height - bounds.height;
-
-    // wtf Apple?!
-    if (max.x < 0)
-        max.x = 0;
-    if (max.y < 0)
-        max.y = 0;
-
-    offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
-    offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
-
-    [scroller setOffset:offset];
-}
-
-@end
-
-/* WebCycript Delegate {{{ */
-@interface WebCycriptDelegate : NSObject {
-    _transient volatile id delegate_;
-}
-
-- (void) setDelegate:(id)delegate;
-- (id) initWithDelegate:(id)delegate;
-@end
-
-@implementation WebCycriptDelegate
-
-- (void) setDelegate:(id)delegate {
-    delegate_ = delegate;
-}
-
-- (id) initWithDelegate:(id)delegate {
-    delegate_ = delegate;
-    return self;
-}
-
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender didClearWindowObject:window forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender didCommitLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender didFailLoadWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender didFinishLoadForFrame:frame];
-}
-
-/*- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender didReceiveTitle:title forFrame:frame];
-}*/
-
-- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender didStartProvisionalLoadForFrame:frame];
-}
-
-/*- (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
-}*/
-
-/*- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
-    if (delegate_ != nil)
-        return [delegate_ webView:sender resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:source];
-    return nil;
-}*/
-
-- (IMP) methodForSelector:(SEL)sel {
-    if (IMP method = [super methodForSelector:sel])
-        return method;
-    fprintf(stderr, "methodForSelector:[%s] == NULL\n", sel_getName(sel));
-    return NULL;
-}
-
-- (BOOL) respondsToSelector:(SEL)sel {
-    if ([super respondsToSelector:sel])
-        return YES;
-    // XXX: WebThreadCreateNSInvocation returns nil
-    //fprintf(stderr, "[%s]R?%s\n", class_getName(self->isa), sel_getName(sel));
-    return delegate_ == nil ? NO : [delegate_ respondsToSelector:sel];
-}
-
-- (NSMethodSignature *) methodSignatureForSelector:(SEL)sel {
-    if (NSMethodSignature *method = [super methodSignatureForSelector:sel])
-        return method;
-    //fprintf(stderr, "[%s]S?%s\n", class_getName(self->isa), sel_getName(sel));
-    if (delegate_ != nil)
-        if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel])
-            return sig;
-    // XXX: I fucking hate Apple so very very bad
-    return [NSMethodSignature signatureWithObjCTypes:"v@:"];
-}
-
-- (void) forwardInvocation:(NSInvocation *)inv {
-    SEL sel = [inv selector];
-    if (delegate_ != nil && [delegate_ respondsToSelector:sel])
-        [inv invokeWithTarget:delegate_];
-}
-
-@end
-/* }}} */
-
-@interface WebCydgetLockScreenView : UIView {
-    WebCycriptDelegate *indirect_;
-    UIProgressIndicator *indicator_;
-    UIScroller *scroller_;
-    UIWebDocumentView *document_;
-
-    float width_;
-    CGSize size_;
-    bool editing_;
-
-    NSNumber *confirm_;
-
-    NSMutableSet *loading_;
-    bool error_;
-    bool reloading_;
-}
-
-@end
-
-@implementation WebCydgetLockScreenView
-
-//#include "UICaboodle/UCInternal.h"
-
-- (void) dealloc {
-_trace();
-    WebThreadLock();
-
-    WebView *webview([document_ webView]);
-    [webview setFrameLoadDelegate:nil];
-    [webview setResourceLoadDelegate:nil];
-    [webview setUIDelegate:nil];
-    [webview setScriptDebugDelegate:nil];
-    [webview setPolicyDelegate:nil];
-
-    /* XXX: these are set by UIWebDocumentView
-    [webview setDownloadDelegate:nil];
-    [webview _setFormDelegate:nil];
-    [webview _setUIKitDelegate:nil];
-    [webview setEditingDelegate:nil];*/
-
-    /* XXX: no one sets this, ever
-    [webview setWebMailDelegate:nil];*/
-
-    [document_ setDelegate:nil];
-    [document_ setGestureDelegate:nil];
-    [document_ setFormEditingDelegate:nil];
-    [document_ setInteractionDelegate:nil];
-
-    [indirect_ setDelegate:nil];
-
-    [webview close];
-    [document_ release];
-
-    [indirect_ release];
-
-    WebThreadUnlock();
-
-    [scroller_ setDelegate:nil];
-
-    if (confirm_ != nil)
-        [confirm_ release];
-
-    [scroller_ release];
-    [indicator_ release];
-    [super dealloc];
-}
-
-+ (float) defaultWidth {
-    return 980;
-}
-
-- (void) _setTileDrawingEnabled:(BOOL)enabled {
-    //[document_ setTileDrawingEnabled:enabled];
-}
-
-- (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
-    [self _setTileDrawingEnabled:NO];
-}
-
-- (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
-    [self _setTileDrawingEnabled:YES];
-    [document_ redrawScaledDocument];
-}
-
-- (void) setViewportWidth:(float)width {
-    width_ = width != 0 ? width : [[self class] defaultWidth];
-    [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
-}
-
-- (void) scrollerWillStartDragging:(UIScroller *)scroller {
-    [self _setTileDrawingEnabled:NO];
-}
-
-- (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
-    [self _setTileDrawingEnabled:YES];
-}
-
-- (void) scrollerDidEndDragging:(UIScroller *)scroller {
-    [self _setTileDrawingEnabled:YES];
-}
-
-- (void) loadRequest:(NSURLRequest *)request {
-    error_ = false;
-
-    WebThreadLock();
-    [document_ loadRequest:request];
-    WebThreadUnlock();
-}
-
-- (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
-    [self loadRequest:[NSURLRequest
-        requestWithURL:url
-        cachePolicy:policy
-        timeoutInterval:30.0
-    ]];
-}
-
-- (void) loadURL:(NSURL *)url {
-    [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
-}
-
-- (id) init {
-    CGRect frame = {{0, 0}, {320, 480}};
-    frame.size.height -= GSDefaultStatusBarHeight();
-
-    if ((self = [super initWithFrame:frame]) != nil) {
-        struct CGRect bounds([self bounds]);
-
-        scroller_ = [[UIScroller alloc] initWithFrame:bounds];
-        [self addSubview:scroller_];
-
-        [scroller_ setFixedBackgroundPattern:YES];
-        [scroller_ setBackgroundColor:[UIColor blackColor]];
-
-        [scroller_ setScrollingEnabled:YES];
-        [scroller_ setClipsSubviews:YES];
-        [scroller_ setAllowsRubberBanding:YES];
-
-        [scroller_ setDelegate:self];
-        [scroller_ setBounces:YES];
-        [scroller_ setScrollHysteresis:8];
-        [scroller_ setThumbDetectionEnabled:NO];
-        [scroller_ setDirectionalScrolling:YES];
-        [scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
-        [scroller_ setEventMode:YES];
-        [scroller_ setShowBackgroundShadow:NO]; /* YES */
-        [scroller_ setAllowsRubberBanding:YES]; /* Vertical */
-        [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
-
-        CGRect rect([scroller_ bounds]);
-        //rect.size.height = 0;
-
-        WebThreadLock();
-
-        document_ = [[UIWebDocumentView alloc] initWithFrame:rect];
-        WebView *webview([document_ webView]);
-
-        [document_ setBackgroundColor:[UIColor blackColor]];
-        if ([document_ respondsToSelector:@selector(setDrawsBackground:)])
-            [document_ setDrawsBackground:NO];
-        [webview setDrawsBackground:NO];
-
-        [webview setPreferencesIdentifier:@"WebCycript"];
-
-        [document_ setTileSize:CGSizeMake(rect.size.width, 500)];
-
-        if ([document_ respondsToSelector:@selector(enableReachability)])
-            [document_ enableReachability];
-
-        [document_ setAllowsMessaging:YES];
-
-        if ([document_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
-            [document_ useSelectionAssistantWithMode:0];
-
-        [document_ setTilingEnabled:YES];
-        [document_ setDrawsGrid:NO];
-        [document_ setLogsTilingChanges:NO];
-        [document_ setTileMinificationFilter:kCAFilterNearest];
-
-        if ([document_ respondsToSelector:@selector(setDataDetectorTypes:)])
-            /* XXX: abstractify */
-            [document_ setDataDetectorTypes:0x80000000];
-        else
-            [document_ setDetectsPhoneNumbers:NO];
-
-        [document_ setAutoresizes:YES];
-
-        [document_ setMinimumScale:0.25f forDocumentTypes:0x10];
-        [document_ setMaximumScale:5.00f forDocumentTypes:0x10];
-        [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
-        //[document_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
-
-        [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
-
-        [document_ setMinimumScale:1.00f forDocumentTypes:0x8];
-        [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
-        [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
-
-        [document_ _setDocumentType:0x4];
-
-        if ([document_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
-            [document_ setZoomsFocusedFormControl:YES];
-        [document_ setContentsPosition:7];
-        [document_ setEnabledGestures:0xa];
-        [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
-        [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
-
-        [document_ setSmoothsFonts:YES];
-        [document_ setAllowsImageSheet:YES];
-        [webview _setUsesLoaderCache:YES];
-
-        [webview setGroupName:@"CydgetGroup"];
-
-        WebPreferences *preferences([webview preferences]);
-
-        if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
-            [webview _setLayoutInterval:0];
-        else
-            [preferences _setLayoutInterval:0];
-
-        [self setViewportWidth:0];
-
-        [document_ setDelegate:self];
-        [document_ setGestureDelegate:self];
-        [document_ setFormEditingDelegate:self];
-        [document_ setInteractionDelegate:self];
-
-        [scroller_ addSubview:document_];
-
-        //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
-
-        indirect_ = [[WebCycriptDelegate alloc] initWithDelegate:self];
-
-        [webview setFrameLoadDelegate:indirect_];
-        [webview setPolicyDelegate:indirect_];
-        [webview setResourceLoadDelegate:indirect_];
-        [webview setUIDelegate:indirect_];
-
-        /* XXX: do not turn this on under penalty of extreme pain */
-        [webview setScriptDebugDelegate:nil];
-
-        WebThreadUnlock();
-
-        CGSize indsize([UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite]);
-        indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 12, indsize.width, indsize.height)];
-        [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
-
-        [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
-        [scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
-
-        NSDictionary *configuration([$CydgetController currentConfiguration]);
-        NSString *homepage([configuration objectForKey:@"Homepage"]);
-        [self loadURL:[NSURL URLWithString:homepage]];
-    } return self;
-}
-
-- (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
-    [self retain];
-
-    UIActionSheet *sheet = [[[UIActionSheet alloc]
-        initWithTitle:nil
-        buttons:[NSArray arrayWithObjects:@"OK", nil]
-        defaultButtonIndex:0
-        delegate:self
-        context:@"alert"
-    ] autorelease];
-
-    [sheet setBodyText:message];
-    [sheet popupAlertAnimated:YES];
-}
-
-- (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
-    [self retain];
-
-    UIActionSheet *sheet = [[[UIActionSheet alloc]
-        initWithTitle:nil
-        buttons:[NSArray arrayWithObjects:@"OK", @"CANCEL", nil]
-        defaultButtonIndex:0
-        delegate:indirect_
-        context:@"confirm"
-    ] autorelease];
-
-    [sheet setNumberOfRows:1];
-    [sheet setBodyText:message];
-    [sheet popupAlertAnimated:YES];
-
-    NSRunLoop *loop([NSRunLoop currentRunLoop]);
-    NSDate *future([NSDate distantFuture]);
-
-    while (confirm_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
-
-    NSNumber *confirm([confirm_ autorelease]);
-    confirm_ = nil;
-
-    [self autorelease];
-    return [confirm boolValue];
-}
-
-/* XXX: WebThreadLock? */
-- (void) _fixScroller:(CGRect)bounds {
-    float extra;
-    if (!editing_)
-        extra = 0;
-    else {
-        UIFormAssistant *assistant([UIFormAssistant sharedFormAssistant]);
-        CGRect peripheral([assistant peripheralFrame]);
-        extra = peripheral.size.height;
-    }
-
-    CGRect subrect([scroller_ frame]);
-    subrect.size.height -= extra;
-    [scroller_ setScrollerIndicatorSubrect:subrect];
-
-    NSSize visible(NSMakeSize(subrect.size.width, subrect.size.height));
-    [document_ setValue:[NSValue valueWithSize:visible] forGestureAttribute:UIGestureAttributeVisibleSize];
-
-    CGSize size(size_);
-    size.height += extra;
-    [scroller_ setContentSize:size];
-
-    [scroller_ releaseRubberBandIfNecessary];
-}
-
-- (void) fixScroller {
-    CGRect bounds([document_ documentBounds]);
-    [self _fixScroller:bounds];
-}
-
-- (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
-    size_ = frame.size;
-    [self _fixScroller:frame];
-}
-
-- (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
-    [self view:sender didSetFrame:frame];
-}
-
-- (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
-    editing_ = true;
-}
-
-- (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
-    [self fixScroller];
-}
-
-- (void) webViewDidEndEditingFormElements:(WebView *)sender {
-    editing_ = false;
-    [self fixScroller];
-}
-
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
-}
-
-- (bool) isLoading {
-    return [loading_ count] != 0;
-}
-
-- (void) reloadButtons {
-    if ([self isLoading])
-        [indicator_ startAnimation];
-    else
-        [indicator_ stopAnimation];
-}
-
-- (void) _finishLoading {
-    size_t count([loading_ count]);
-    /*if (count == 0)
-        [self autorelease];*/
-    if (reloading_ || count != 0)
-        return;
-    [self reloadButtons];
-}
-
-- (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
-    return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
-    return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
-    return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
-    return [document_ webView:sender didCommitLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
-    return [document_ webView:sender didReceiveDocTypeForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
-    [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
-    [self _finishLoading];
-    return [document_ webView:sender didFinishLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
-    /*if ([loading_ count] == 0)
-        [self retain];*/
-    [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
-
-    if ([frame parentFrame] == nil) {
-        [document_ resignFirstResponder];
-
-        reloading_ = false;
-
-        [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
-
-        if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
-            [scroller_ setZoomScale:1 duration:0];
-        else if ([scroller_ respondsToSelector:@selector(_setZoomScale:duration:)])
-            [scroller_ _setZoomScale:1 duration:0];
-        /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
-            [scroller_ setZoomScale:1 animated:NO];*/
-
-        CGRect rect([scroller_ bounds]);
-        //rect.size.height = 0;
-        [document_ setFrame:rect];
-    }
-
-    [self reloadButtons];
-}
-
-- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
-    _trace();
-    /*if ([frame parentFrame] == nil)
-        [self autorelease];*/
-
-    [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
-    [self _finishLoading];
-
-    if (reloading_)
-        return;
-
-    if ([frame parentFrame] == nil) {
-        [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
-            [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
-            [[error localizedDescription] stringByAddingPercentEscapes]
-        ]]];
-
-        error_ = true;
-    }
-}
-
-- (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
-    [self _didFailWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
-    [self _didFailWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
-    fprintf(stderr, "Console:%s\n", [[dictionary description] UTF8String]);
-}
-
-@end
-
-@interface WebCycriptLockScreenController : SBAwayViewPluginController {
-}
-
-@end
-
-@implementation WebCycriptLockScreenController
-
-+ (id) rootViewController {
-    return [[[self alloc] init] autorelease];
-}
-
-- (void) loadView {
-    [self setView:[[[WebCydgetLockScreenView alloc] init] autorelease]];
-}
-
-@end
diff --git a/webcycript/control b/webcycript/control
deleted file mode 100644 (file)
index 36014f7..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Package: cydget-webcycript
-Priority: optional
-Section: Development
-Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
-Architecture: iphoneos-arm
-Version: 0.9.3073-1
-Description: write LockCydgets using Cycript and HTML
-Name: Cydget WebCycript
-Depends: cydget, cycript
-Author: Jay Freeman (saurik) <saurik@saurik.com>
-Depiction: http://cydia.saurik.com/info/cydget-webcycript/
-Tag: purpose::library, role::developer
diff --git a/webcycript/make.sh b/webcycript/make.sh
deleted file mode 100755 (executable)
index 6d212b3..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-PKG_ARCH=iphoneos-arm /apl/tel/exec.sh - make package "$@"
diff --git a/webcycript/makefile b/webcycript/makefile
deleted file mode 100644 (file)
index fac7d59..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-name := WebCycript
-flags := -lcycript -L/dat/src/cycript -framework QuartzCore -framework WebCore -framework CoreGraphics -framework GraphicsServices
-base := ../../tweaks
-include ../LockScreen.mk
-
-extra:
-       mkdir -p package/System/Library/LockCydgets/CydgetCentral.cydget
-       cp -a CydgetCentral.plist package/System/Library/LockCydgets/CydgetCentral.cydget/Info.plist