1 /* CydgetScript - open-source IntelliDial replacement
2 * Copyright (C) 2009 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.
38 #include <substrate.h>
39 #include <sys/sysctl.h>
41 #import <GraphicsServices/GraphicsServices.h>
42 #import <UIKit/UIKit.h>
43 #import <AddressBook/AddressBook.h>
45 #import <SpringBoard/SBStatusBarController.h>
46 #import <SpringBoardUI/SBAwayViewPluginController.h>
47 #import <TelephonyUI/TPBottomLockBar.h>
49 #import <QuartzCore/CALayer.h>
50 // XXX: fix the minimum requirement
51 extern NSString * const kCAFilterNearest;
53 #include <WebKit/DOMCSSPrimitiveValue.h>
54 #include <WebKit/DOMCSSStyleDeclaration.h>
55 #include <WebKit/DOMDocument.h>
56 #include <WebKit/DOMHTMLBodyElement.h>
57 #include <WebKit/DOMNodeList.h>
58 #include <WebKit/DOMRGBColor.h>
60 #include <WebKit/WebFrame.h>
61 #include <WebKit/WebPolicyDelegate.h>
62 #include <WebKit/WebPreferences.h>
63 #include <WebKit/WebScriptObject.h>
65 #import <WebKit/WebView.h>
66 #import <WebKit/WebView-WebPrivate.h>
68 #include <WebCore/Page.h>
69 #include <WebCore/Settings.h>
71 #include <WebCore/WebCoreThread.h>
72 #include <WebKit/WebPreferences-WebPrivate.h>
74 #include "JSGlobalData.h"
76 #include "SourceCode.h"
77 #include "SourceCode4.h"
79 #include <apr-1/apr_pools.h>
82 @interface WebView (UICaboodle)
83 - (void) setScriptDebugDelegate:(id)delegate;
84 - (void) _setFormDelegate:(id)delegate;
85 - (void) _setUIKitDelegate:(id)delegate;
86 - (void) setWebMailDelegate:(id)delegate;
87 - (void) _setLayoutInterval:(float)interval;
91 #define _forever for (;;)
93 _disused static unsigned trace_;
95 #define _trace() do { \
96 NSLog(@"_trace(%u)@%s:%u[%s]\n", \
97 trace_++, __FILE__, __LINE__, __FUNCTION__\
101 #define _assert(test) do \
103 fprintf(stderr, "_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \
108 #define _syscall(expr) \
109 do if ((long) (expr) != -1) \
111 else switch (errno) { \
118 @protocol CydgetController
119 - (NSDictionary *) currentConfiguration;
122 static Class $CydgetController(objc_getClass("CydgetController"));
123 static Class $UIFormAssistant(objc_getClass("UIFormAssistant"));
124 static Class $SBStatusBarController(objc_getClass("SBStatusBarController"));
126 static Class $UIWebBrowserView;
127 static bool Wildcat_, iOS4;
129 @interface NSString (UIKit)
130 - (NSString *) stringByAddingPercentEscapes;
133 @implementation UIWebDocumentView (WebCycript)
135 - (void) _setScrollerOffset:(CGPoint)offset {
136 UIScroller *scroller([self _scroller]);
138 CGSize size([scroller contentSize]);
139 CGSize bounds([scroller bounds].size);
142 max.x = size.width - bounds.width;
143 max.y = size.height - bounds.height;
151 offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
152 offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
154 [scroller setOffset:offset];
159 /* Perl-Compatible RegEx {{{ */
169 Pcre(const char *regex, int options = 0) :
174 code_ = pcre_compile(regex, options, &error, &offset, NULL);
177 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** Pcre(,): [%u] %s", offset, error] userInfo:nil];
179 pcre_fullinfo(code_, study_, PCRE_INFO_CAPTURECOUNT, &capture_);
180 matches_ = new int[(capture_ + 1) * 3];
188 NSString *operator [](size_t match) {
189 return [[[NSString alloc] initWithBytes:(data_ + matches_[match * 2]) length:(matches_[match * 2 + 1] - matches_[match * 2]) encoding:NSUTF8StringEncoding] autorelease];
192 bool operator ()(NSString *data) {
193 // XXX: length is for characters, not for bytes
194 return operator ()([data UTF8String], [data length]);
197 bool operator ()(const char *data, size_t size) {
199 return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
203 /* WebCycript Delegate {{{ */
204 @interface WebCycriptDelegate : NSObject {
205 _transient volatile id delegate_;
208 - (void) setDelegate:(id)delegate;
209 - (id) initWithDelegate:(id)delegate;
212 @implementation WebCycriptDelegate
214 - (void) setDelegate:(id)delegate {
215 delegate_ = delegate;
218 - (id) initWithDelegate:(id)delegate {
219 delegate_ = delegate;
223 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
224 if (delegate_ != nil)
225 return [delegate_ webView:sender didClearWindowObject:window forFrame:frame];
228 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
229 if (delegate_ != nil)
230 return [delegate_ webView:sender didCommitLoadForFrame:frame];
233 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
234 if (delegate_ != nil)
235 return [delegate_ webView:sender didFailLoadWithError:error forFrame:frame];
238 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
239 if (delegate_ != nil)
240 return [delegate_ webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
243 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
244 if (delegate_ != nil)
245 return [delegate_ webView:sender didFinishLoadForFrame:frame];
248 /*- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
249 if (delegate_ != nil)
250 return [delegate_ webView:sender didReceiveTitle:title forFrame:frame];
253 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
254 if (delegate_ != nil)
255 return [delegate_ webView:sender didStartProvisionalLoadForFrame:frame];
258 /*- (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
259 if (delegate_ != nil)
260 return [delegate_ webView:sender resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
263 /*- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
264 if (delegate_ != nil)
265 return [delegate_ webView:sender resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:source];
269 - (IMP) methodForSelector:(SEL)sel {
270 if (IMP method = [super methodForSelector:sel])
272 fprintf(stderr, "methodForSelector:[%s] == NULL\n", sel_getName(sel));
276 - (BOOL) respondsToSelector:(SEL)sel {
277 if ([super respondsToSelector:sel])
279 // XXX: WebThreadCreateNSInvocation returns nil
280 //fprintf(stderr, "[%s]R?%s\n", class_getName(self->isa), sel_getName(sel));
281 return delegate_ == nil ? NO : [delegate_ respondsToSelector:sel];
284 - (NSMethodSignature *) methodSignatureForSelector:(SEL)sel {
285 if (NSMethodSignature *method = [super methodSignatureForSelector:sel])
287 //fprintf(stderr, "[%s]S?%s\n", class_getName(self->isa), sel_getName(sel));
288 if (delegate_ != nil)
289 if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel])
291 // XXX: I fucking hate Apple so very very bad
292 return [NSMethodSignature signatureWithObjCTypes:"v@:"];
295 - (void) forwardInvocation:(NSInvocation *)inv {
296 SEL sel = [inv selector];
297 if (delegate_ != nil && [delegate_ respondsToSelector:sel])
298 [inv invokeWithTarget:delegate_];
304 @interface WebCydgetLockScreenView : UIView {
305 WebCycriptDelegate *indirect_;
306 UIProgressIndicator *indicator_;
307 UIScroller *scroller_;
308 UIWebDocumentView *document_;
319 NSMutableSet *loading_;
323 //UIKeyboard *keyboard_;
328 @implementation WebCydgetLockScreenView
330 //#include "UICaboodle/UCInternal.h"
335 WebView *webview([document_ webView]);
336 [webview setFrameLoadDelegate:nil];
337 [webview setResourceLoadDelegate:nil];
338 [webview setUIDelegate:nil];
339 [webview setScriptDebugDelegate:nil];
340 [webview setPolicyDelegate:nil];
342 /* XXX: these are set by UIWebDocumentView
343 [webview setDownloadDelegate:nil];
344 [webview _setFormDelegate:nil];
345 [webview _setUIKitDelegate:nil];
346 [webview setEditingDelegate:nil];*/
348 /* XXX: no one sets this, ever
349 [webview setWebMailDelegate:nil];*/
351 [document_ setDelegate:nil];
352 [document_ setGestureDelegate:nil];
354 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
355 [document_ setFormEditingDelegate:nil];
357 [document_ setInteractionDelegate:nil];
359 [indirect_ setDelegate:nil];
368 [scroller_ setDelegate:nil];
373 //[keyboard_ release];
376 [indicator_ release];
381 + (float) defaultWidth {
385 - (void) webView:(WebView *)sender didReceiveMessage:(NSDictionary *)dictionary {
386 #if LogBrowser || ForSaurik
387 lprintf("Console:%s\n", [[dictionary description] UTF8String]);
389 if ([document_ respondsToSelector:@selector(webView:didReceiveMessage:)])
390 [document_ webView:sender didReceiveMessage:dictionary];
393 - (void) webView:(id)sender willCloseFrame:(id)frame {
394 if ([document_ respondsToSelector:@selector(webView:willCloseFrame:)])
395 [document_ webView:sender willCloseFrame:frame];
398 - (void) webView:(id)sender didFinishDocumentLoadForFrame:(id)frame {
399 if ([document_ respondsToSelector:@selector(webView:didFinishDocumentLoadForFrame:)])
400 [document_ webView:sender didFinishDocumentLoadForFrame:frame];
403 - (void) webView:(id)sender didFirstLayoutInFrame:(id)frame {
404 if ([document_ respondsToSelector:@selector(webView:didFirstLayoutInFrame:)])
405 [document_ webView:sender didFirstLayoutInFrame:frame];
408 - (void) webViewFormEditedStatusHasChanged:(id)changed {
409 if ([document_ respondsToSelector:@selector(webViewFormEditedStatusHasChanged:)])
410 [document_ webViewFormEditedStatusHasChanged:changed];
413 - (void) webView:(id)sender formStateDidFocusNode:(id)formState {
414 if ([document_ respondsToSelector:@selector(webView:formStateDidFocusNode:)])
415 [document_ webView:sender formStateDidFocusNode:formState];
418 - (void) webView:(id)sender formStateDidBlurNode:(id)formState {
419 if ([document_ respondsToSelector:@selector(webView:formStateDidBlurNode:)])
420 [document_ webView:sender formStateDidBlurNode:formState];
423 - (void) webViewDidLayout:(id)sender {
424 [document_ webViewDidLayout:sender];
427 - (void) webView:(id)sender didFirstVisuallyNonEmptyLayoutInFrame:(id)frame {
428 [document_ webView:sender didFirstVisuallyNonEmptyLayoutInFrame:frame];
431 - (void) webView:(id)sender saveStateToHistoryItem:(id)item forFrame:(id)frame {
432 [document_ webView:sender saveStateToHistoryItem:item forFrame:frame];
435 - (void) webView:(id)sender restoreStateFromHistoryItem:(id)item forFrame:(id)frame force:(BOOL)force {
436 [document_ webView:sender restoreStateFromHistoryItem:item forFrame:frame force:force];
439 - (void) webView:(id)sender attachRootLayer:(id)layer {
440 [document_ webView:sender attachRootLayer:layer];
443 - (id) webView:(id)sender plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package {
444 return [document_ webView:sender plugInViewWithArguments:arguments fromPlugInPackage:package];
447 - (void) webView:(id)sender willShowFullScreenForPlugInView:(id)view {
448 [document_ webView:sender willShowFullScreenForPlugInView:view];
451 - (void) webView:(id)sender didHideFullScreenForPlugInView:(id)view {
452 [document_ webView:sender didHideFullScreenForPlugInView:view];
455 - (void) webView:(id)sender willAddPlugInView:(id)view {
456 [document_ webView:sender willAddPlugInView:view];
459 - (void) webView:(id)sender didObserveDeferredContentChange:(int)change forFrame:(id)frame {
460 [document_ webView:sender didObserveDeferredContentChange:change forFrame:frame];
463 - (void) webViewDidPreventDefaultForEvent:(id)sender {
464 [document_ webViewDidPreventDefaultForEvent:sender];
467 - (void) _setTileDrawingEnabled:(BOOL)enabled {
468 //[document_ setTileDrawingEnabled:enabled];
471 - (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
472 [self _setTileDrawingEnabled:NO];
475 - (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
476 [self _setTileDrawingEnabled:YES];
477 [document_ redrawScaledDocument];
480 - (void) setViewportWidth:(float)width {
481 width_ = width != 0 ? width : [[self class] defaultWidth];
482 [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
485 - (void) scrollerWillStartDragging:(UIScroller *)scroller {
486 [self _setTileDrawingEnabled:NO];
489 - (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
490 [self _setTileDrawingEnabled:YES];
493 - (void) scrollerDidEndDragging:(UIScroller *)scroller {
494 [self _setTileDrawingEnabled:YES];
497 - (void) loadRequest:(NSURLRequest *)request {
501 [document_ loadRequest:request];
505 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
506 [self loadRequest:[NSURLRequest
513 - (void) loadURL:(NSURL *)url {
514 [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
518 CGRect frame = {{0, 0}, {320, 480}};
519 frame.size.height -= 20; //[[[$SBStatusBarController sharedStatusBarController] statusBarView] frame].size.height;
521 if ((self = [super initWithFrame:frame]) != nil) {
522 loading_ = [[NSMutableSet alloc] initWithCapacity:3];
524 struct CGRect bounds([self bounds]);
526 scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
527 [self addSubview:scroller_];
529 [scroller_ setFixedBackgroundPattern:YES];
530 [scroller_ setBackgroundColor:[UIColor blackColor]];
532 [scroller_ setScrollingEnabled:YES];
533 [scroller_ setClipsSubviews:YES];
536 [scroller_ setAllowsRubberBanding:YES];
538 [scroller_ setDelegate:self];
539 [scroller_ setBounces:YES];
542 [scroller_ setScrollHysteresis:8];
543 [scroller_ setThumbDetectionEnabled:NO];
544 [scroller_ setDirectionalScrolling:YES];
545 //[scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
546 [scroller_ setEventMode:YES];
550 UIScrollView *scroller((UIScrollView *)scroller_);
551 //[scroller setDirectionalLockEnabled:NO];
552 [scroller setDelaysContentTouches:NO];
553 //[scroller setScrollsToTop:NO];
554 //[scroller setCanCancelContentTouches:NO];
557 [scroller_ setShowBackgroundShadow:NO]; /* YES */
558 //[scroller_ setAllowsRubberBanding:YES]; /* Vertical */
561 [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
563 CGRect rect([scroller_ bounds]);
564 //rect.size.height = 0;
568 document_ = [[$UIWebBrowserView alloc] initWithFrame:rect];
569 WebView *webview([document_ webView]);
571 [document_ setBackgroundColor:[UIColor blackColor]];
572 if ([document_ respondsToSelector:@selector(setDrawsBackground:)])
573 [document_ setDrawsBackground:NO];
574 [webview setDrawsBackground:NO];
576 [webview setPreferencesIdentifier:@"WebCycript"];
578 [document_ setTileSize:CGSizeMake(rect.size.width, 500)];
580 if ([document_ respondsToSelector:@selector(enableReachability)])
581 [document_ enableReachability];
582 if ([document_ respondsToSelector:@selector(setAllowsMessaging:)])
583 [document_ setAllowsMessaging:YES];
584 if ([document_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
585 [document_ useSelectionAssistantWithMode:0];
587 [document_ setTilingEnabled:YES];
588 [document_ setDrawsGrid:NO];
589 [document_ setLogsTilingChanges:NO];
590 [document_ setTileMinificationFilter:kCAFilterNearest];
592 if ([document_ respondsToSelector:@selector(setDataDetectorTypes:)])
593 /* XXX: abstractify */
594 [document_ setDataDetectorTypes:0x80000000];
596 [document_ setDetectsPhoneNumbers:NO];
598 [document_ setAutoresizes:YES];
600 [document_ setMinimumScale:0.25f forDocumentTypes:0x10];
601 [document_ setMaximumScale:5.00f forDocumentTypes:0x10];
602 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
603 //[document_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
605 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
607 [document_ setMinimumScale:1.00f forDocumentTypes:0x8];
608 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
609 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
611 [document_ _setDocumentType:0x4];
613 if ([document_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
614 [document_ setZoomsFocusedFormControl:YES];
615 [document_ setContentsPosition:7];
616 [document_ setEnabledGestures:0xa];
617 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
618 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
620 [document_ setSmoothsFonts:YES];
621 [document_ setAllowsImageSheet:YES];
622 [webview _setUsesLoaderCache:YES];
624 [webview setGroupName:@"CydgetGroup"];
626 WebPreferences *preferences([webview preferences]);
628 if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
629 [webview _setLayoutInterval:0];
631 [preferences _setLayoutInterval:0];
633 [self setViewportWidth:0];
635 [document_ setDelegate:self];
636 [document_ setGestureDelegate:self];
638 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
639 [document_ setFormEditingDelegate:self];
640 [document_ setInteractionDelegate:self];
642 [scroller_ addSubview:document_];
644 //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
646 indirect_ = [[WebCycriptDelegate alloc] initWithDelegate:self];
648 [webview setFrameLoadDelegate:indirect_];
649 [webview setPolicyDelegate:indirect_];
650 [webview setResourceLoadDelegate:indirect_];
651 [webview setUIDelegate:indirect_];
653 /* XXX: do not turn this on under penalty of extreme pain */
654 [webview setScriptDebugDelegate:nil];
658 CGSize indsize([UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite]);
659 indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 12, indsize.width, indsize.height)];
660 [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
662 [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
663 [scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
665 NSDictionary *configuration([$CydgetController currentConfiguration]);
667 cycript_ = [configuration objectForKey:@"CycriptURLs"];
669 scrollable_ = [[configuration objectForKey:@"Scrollable"] boolValue];
670 [scroller_ setScrollingEnabled:scrollable_];
672 NSString *homepage([configuration objectForKey:@"Homepage"]);
673 [self loadURL:[NSURL URLWithString:homepage]];
675 /*[UIKeyboard initImplementationNow];
676 CGSize keysize = [UIKeyboard defaultSize];
677 CGRect keyrect = {{0, [self bounds].size.height - 100}, keysize};
678 keyboard_ = [[UIKeyboard alloc] initWithFrame:keyrect];
679 [self addSubview:keyboard_];
681 [self addSubview:[[UITextView alloc] initWithFrame:CGRectMake(200, 0, 100, 100)]];
682 [self addSubview:[[UITextView alloc] initWithFrame:CGRectMake(200, 150, 100, 100)]];
683 [self addSubview:[[UITextView alloc] initWithFrame:CGRectMake(200, 300, 100, 100)]];*/
687 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
690 UIActionSheet *sheet = [[[UIActionSheet alloc]
692 buttons:[NSArray arrayWithObjects:@"OK", nil]
698 [sheet setBodyText:message];
699 [sheet popupAlertAnimated:YES];
702 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
705 UIActionSheet *sheet = [[[UIActionSheet alloc]
707 buttons:[NSArray arrayWithObjects:@"OK", @"CANCEL", nil]
713 [sheet setNumberOfRows:1];
714 [sheet setBodyText:message];
715 [sheet popupAlertAnimated:YES];
717 NSRunLoop *loop([NSRunLoop currentRunLoop]);
718 NSDate *future([NSDate distantFuture]);
720 while (confirm_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
722 NSNumber *confirm([confirm_ autorelease]);
726 return [confirm boolValue];
729 /* XXX: WebThreadLock? */
730 - (void) _fixScroller:(CGRect)bounds {
732 if (!editing_ || $UIFormAssistant == nil)
735 UIFormAssistant *assistant([$UIFormAssistant sharedFormAssistant]);
736 CGRect peripheral([assistant peripheralFrame]);
737 extra = peripheral.size.height;
740 CGRect subrect([scroller_ frame]);
741 subrect.size.height -= [TPBottomLockBar defaultHeight];
742 subrect.size.height -= extra;
744 if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
745 [scroller_ setScrollerIndicatorSubrect:subrect];
747 [document_ setValue:[NSValue valueWithSize:NSMakeSize(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
750 size.height += extra;
751 size.height += [TPBottomLockBar defaultHeight];
752 [scroller_ setContentSize:size];
754 if ([scroller_ respondsToSelector:@selector(releaseRubberBandIfNecessary)])
755 [scroller_ releaseRubberBandIfNecessary];
758 - (void) fixScroller {
759 CGRect bounds([document_ documentBounds]);
760 [self _fixScroller:bounds];
763 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
765 [self _fixScroller:frame];
768 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
769 [self view:sender didSetFrame:frame];
772 - (void) formAssistant:(id)sender didBeginEditingFormNode:(id)node {
775 - (void) formAssistant:(id)sender didEndEditingFormNode:(id)node {
779 - (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
783 - (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
787 - (void) webViewDidEndEditingFormElements:(WebView *)sender {
792 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
794 if (NSString *href = [[[[frame dataSource] request] URL] absoluteString])
795 if (Pcre([cycript_ UTF8String], 0 /*XXX:PCRE_UTF8*/)(href))
796 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
797 if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
798 WebView *webview([document_ webView]);
799 WebFrame *frame([webview mainFrame]);
800 JSGlobalContextRef context([frame globalContext]);
801 CYSetupContext(context);
806 return [loading_ count] != 0;
809 - (void) reloadButtons {
810 if ([self isLoading]) {
811 [UIApp setNetworkActivityIndicatorVisible:YES];
812 [indicator_ startAnimation];
814 [UIApp setNetworkActivityIndicatorVisible:NO];
815 [indicator_ stopAnimation];
819 - (void) _finishLoading {
820 size_t count([loading_ count]);
822 [self autorelease];*/
823 if (reloading_ || count != 0)
825 [self reloadButtons];
828 - (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
829 return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
832 - (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
833 return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
836 - (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
837 return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
840 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
841 return [document_ webView:sender didCommitLoadForFrame:frame];
844 - (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
845 return [document_ webView:sender didReceiveDocTypeForFrame:frame];
848 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
849 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
850 [self _finishLoading];
851 return [document_ webView:sender didFinishLoadForFrame:frame];
854 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
855 /*if ([loading_ count] == 0)
857 [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
859 if ([frame parentFrame] == nil) {
860 [document_ resignFirstResponder];
865 CGRect webrect = [scroller_ bounds];
866 webrect.size.height = 1;
867 [document_ setFrame:webrect];
870 if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
871 [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
873 [scroller_ scrollRectToVisible:CGRectZero animated:NO];
875 if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
876 [scroller_ setZoomScale:1 duration:0];
877 else if ([scroller_ respondsToSelector:@selector(_setZoomScale:duration:)])
878 [scroller_ _setZoomScale:1 duration:0];
879 /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
880 [scroller_ setZoomScale:1 animated:NO];*/
883 CGRect webrect = [scroller_ bounds];
884 webrect.size.height = 1;
885 [document_ setFrame:webrect];
889 [self reloadButtons];
892 - (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
893 /*if ([frame parentFrame] == nil)
894 [self autorelease];*/
896 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
897 [self _finishLoading];
902 if ([frame parentFrame] == nil) {
903 [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
904 [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
905 [[error localizedDescription] stringByAddingPercentEscapes]
912 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
913 [self _didFailWithError:error forFrame:frame];
914 if ([document_ respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
915 [document_ webView:sender didFailLoadWithError:error forFrame:frame];
918 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
919 [self _didFailWithError:error forFrame:frame];
922 - (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
923 fprintf(stderr, "Console:%s\n", [[dictionary description] UTF8String]);
928 @interface WebCycriptLockScreenController : SBAwayViewPluginController {
935 static bool cycript_;
936 static bool jscript_;
938 static void SetParser(bool cycript, bool jscript) {
943 static bool GetParser0() {
947 static bool GetParser1() {
951 static void Cycriptify(apr_pool_t *pool, const uint16_t *&data, size_t &size) {
952 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
953 if (void (*CYParseUChar)(apr_pool_t *, const uint16_t **, size_t *) = reinterpret_cast<void (*)(apr_pool_t *, const uint16_t **, size_t *)>(dlsym(handle, "CydgetPoolParse")))
954 CYParseUChar(pool, &data, &size);
957 extern "C" void *_ZN3JSC7UString3Rep14nullBaseStringE __attribute__((__weak_import__));
958 extern "C" void *_ZN3JSC7UString3Rep7destroyEv __attribute__((__weak_import__));
959 extern "C" void *_ZN3JSC7UStringC1EPKti __attribute__((__weak_import__));
960 extern "C" void *_ZN3JSC7UStringC1EPKc __attribute__((__weak_import__));
961 extern "C" void *_ZNK3JSC7UString6substrEii __attribute__((__weak_import__));
962 extern "C" void *_ZN3WTF10fastMallocEm __attribute__((__weak_import__));
963 extern "C" void WTFReportAssertionFailure(const char *, int, const char *, const char *) __attribute__((__weak_import__));
964 extern "C" void *_ZN3WTF8fastFreeEPv __attribute__((__weak_import__));
968 &_ZN3JSC7UString3Rep14nullBaseStringE == NULL ||
969 &_ZN3JSC7UString3Rep7destroyEv == NULL ||
970 &_ZN3JSC7UStringC1EPKti == NULL ||
971 &_ZN3JSC7UStringC1EPKc == NULL ||
972 &_ZNK3JSC7UString6substrEii == NULL ||
973 &_ZN3WTF10fastMallocEm == NULL ||
974 &WTFReportAssertionFailure == NULL ||
975 &_ZN3WTF8fastFreeEPv == NULL ||
979 MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, void **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
981 return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
983 SetParser(false, true);
985 const uint16_t *data;
988 JSC::SourceCode *source(reinterpret_cast<JSC::SourceCode *>(_this[0]));
989 JSC::SourceCode4 *source4(reinterpret_cast<JSC::SourceCode4 *>(_this[13]));
992 data = source4->data();
993 size = source4->length();
995 data = source->data();
996 size = source->length();
1000 apr_pool_create(&pool, NULL);
1002 //NSLog(@"!:%u:%@", size, [[[NSString alloc] initWithBytes:const_cast<char *>(reinterpret_cast<const char *>(data)) length:size encoding:NSUnicodeStringEncoding] autorelease]);
1003 Cycriptify(pool, data, size);
1004 //NSLog(@"%:%u:%@", size, [[[NSString alloc] initWithBytes:const_cast<char *>(reinterpret_cast<const char *>(data)) length:size encoding:NSUnicodeStringEncoding] autorelease]);
1008 source4->~SourceCode4();
1010 new (source4) JSC::SourceCode4(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
1013 source->~SourceCode();
1014 new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
1017 apr_pool_destroy(pool);
1019 __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
1023 MSHook(void, _ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE, void *_this, int start, const UChar *code, unsigned length, int *source, int *line, JSC::UString *message) {
1025 return __ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE(_this, start, code, length, source, line, message);
1027 const uint16_t *data(code);
1028 size_t size(length);
1031 apr_pool_create(&pool, NULL);
1033 Cycriptify(pool, data, size);
1034 __ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE(_this, start, data, size, source, line, message);
1036 apr_pool_destroy(pool);
1044 MSHook(State, _ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE, State state) {
1045 SetParser(false, true);
1046 state = __ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE(state);
1047 SetParser(false, false);
1051 MSHook(void, _ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE, void *resource) {
1052 SetParser(false, true);
1053 __ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE(resource);
1054 SetParser(false, false);
1057 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
1058 if (!GetParser1() || mime != "text/cycript")
1059 return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
1061 static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
1065 SetParser(true, true);
1069 /* Cydget:// Protocol {{{ */
1070 @interface CydgetURLProtocol : NSURLProtocol {
1075 @implementation CydgetURLProtocol
1077 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
1078 NSURL *url([request URL]);
1081 NSString *scheme([[url scheme] lowercaseString]);
1082 if (scheme == nil || ![scheme isEqualToString:@"cydget"])
1087 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
1091 - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
1092 id<NSURLProtocolClient> client([self client]);
1094 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
1096 NSData *data(UIImagePNGRepresentation(icon));
1098 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
1099 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
1100 [client URLProtocol:self didLoadData:data];
1101 [client URLProtocolDidFinishLoading:self];
1105 - (void) startLoading {
1106 id<NSURLProtocolClient> client([self client]);
1107 NSURLRequest *request([self request]);
1109 NSURL *url([request URL]);
1110 NSString *href([url absoluteString]);
1112 NSString *path([href substringFromIndex:9]);
1113 NSRange slash([path rangeOfString:@"/"]);
1116 if (slash.location == NSNotFound) {
1120 command = [path substringToIndex:slash.location];
1121 path = [path substringFromIndex:(slash.location + 1)];
1124 if ([command isEqualToString:@"_UIImageWithName"]) {
1127 path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
1128 UIImage *icon(_UIImageWithName(path));
1129 [self _returnPNGWithImage:icon forRequest:request];
1131 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
1135 - (void) stopLoading {
1140 /* Cydget-CGI:// Protocol {{{ */
1141 @interface CydgetCGIURLProtocol : NSURLProtocol {
1143 CFHTTPMessageRef http_;
1144 NSFileHandle *handle_;
1149 @implementation CydgetCGIURLProtocol
1151 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
1152 NSURL *url([request URL]);
1155 NSString *scheme([[url scheme] lowercaseString]);
1156 if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
1161 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
1165 - (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)response client:(id<NSURLProtocolClient>)client {
1166 if ((self = [super initWithRequest:request cachedResponse:response client:client]) != nil) {
1171 - (void) startLoading {
1172 id<NSURLProtocolClient> client([self client]);
1173 NSURLRequest *request([self request]);
1174 NSURL *url([request URL]);
1176 NSString *path([url path]);
1178 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
1182 NSFileManager *manager([NSFileManager defaultManager]);
1183 if (![manager fileExistsAtPath:path]) {
1184 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
1189 _assert(pipe(fds) != -1);
1191 _assert(pid_ == -1);
1194 _assert(close(fds[0]) != -1);
1195 _assert(close(fds[1]) != -1);
1196 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
1201 const char *script([path UTF8String]);
1203 setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
1204 setenv("SCRIPT_FILENAME", script, true);
1205 NSString *query([url query]);
1207 setenv("QUERY_STRING", [query UTF8String], true);
1209 _assert(dup2(fds[1], 1) != -1);
1210 _assert(close(fds[0]) != -1);
1211 _assert(close(fds[1]) != -1);
1213 execl(script, script, NULL);
1218 _assert(close(fds[1]) != -1);
1220 _assert(http_ == NULL);
1221 http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
1222 CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
1224 _assert(handle_ == nil);
1225 handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
1227 [[NSNotificationCenter defaultCenter]
1229 selector:@selector(onRead:)
1230 name:@"NSFileHandleReadCompletionNotification"
1234 [handle_ readInBackgroundAndNotify];
1237 - (void) onRead:(NSNotification *)notification {
1238 NSFileHandle *handle([notification object]);
1240 NSData *data([[notification userInfo] objectForKey:NSFileHandleNotificationDataItem]);
1242 if (size_t length = [data length]) {
1243 CFHTTPMessageAppendBytes(http_, reinterpret_cast<const UInt8 *>([data bytes]), length);
1244 [handle readInBackgroundAndNotify];
1246 id<NSURLProtocolClient> client([self client]);
1248 CFStringRef mime(CFHTTPMessageCopyHeaderFieldValue(http_, CFSTR("Content-type")));
1250 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:nil]];
1252 NSURLRequest *request([self request]);
1254 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:(NSString *)mime expectedContentLength:-1 textEncodingName:nil] autorelease]);
1257 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
1259 CFDataRef body(CFHTTPMessageCopyBody(http_));
1260 [client URLProtocol:self didLoadData:(NSData *)body];
1263 [client URLProtocolDidFinishLoading:self];
1271 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
1273 - (void) stopLoading_ {
1274 [[NSNotificationCenter defaultCenter] removeObserver:self];
1276 if (handle_ != nil) {
1282 kill(pid_, SIGTERM);
1284 _syscall(waitpid(pid_, &status, 0));
1289 - (void) stopLoading {
1291 performSelectorOnMainThread:@selector(stopLoading_)
1300 template <typename Type_>
1301 static void nlset(Type_ &function, struct nlist *nl, size_t index) {
1302 struct nlist &name(nl[index]);
1303 uintptr_t value(name.n_value);
1304 if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
1305 value |= 0x00000001;
1306 function = reinterpret_cast<Type_>(value);
1309 template <typename Type_>
1310 static void dlset(Type_ &function, const char *name) {
1311 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
1314 @implementation WebCycriptLockScreenController
1316 + (void) initialize {
1317 iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
1319 $UIWebBrowserView = objc_getClass("UIWebBrowserView");
1320 if ($UIWebBrowserView == nil) {
1322 $UIWebBrowserView = objc_getClass("UIWebDocumentView");
1328 size_t size(sizeof(maxproc));
1329 if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
1330 NSLog(@"sysctlbyname(\"kern.maxproc\", ?)");
1331 else if (maxproc < 72) {
1333 if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1)
1334 NSLog(@"sysctlbyname(\"kern.maxproc\", #)");
1339 [NSURLProtocol registerClass:[CydgetURLProtocol class]];
1340 [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
1342 void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(void **, JSC::JSGlobalData *, int *, JSC::UString *);
1343 dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
1344 if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
1345 MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
1347 void (*_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE)(void *, int, const UChar *, unsigned, int *, int *, JSC::UString *);
1348 dlset(_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE, "_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE");
1349 if (_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE != NULL)
1350 MSHookFunction(_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE, MSHake(_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE));
1353 memset(nl, 0, sizeof(nl));
1354 nl[0].n_un.n_name = (char *) "__ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE";
1355 nl[1].n_un.n_name = (char *) "__ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE";
1356 nl[2].n_un.n_name = (char *) "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE";
1357 nlist("/System/Library/PrivateFrameworks/WebCore.framework/WebCore", nl);
1359 State (*_ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE)(State);
1360 nlset(_ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE, nl, 0);
1361 MSHookFunction(_ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE));
1363 void (*_ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE)(void *);
1364 nlset(_ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE, nl, 1);
1365 MSHookFunction(_ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE, MSHake(_ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE));
1367 bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &);
1368 nlset(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, nl, 2);
1369 MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
1372 + (id) rootViewController {
1373 return [[[self alloc] init] autorelease];
1377 [self setView:[[[WebCydgetLockScreenView alloc] init] autorelease]];