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"
78 #include <apr-1/apr_pools.h>
81 @interface WebView (UICaboodle)
82 - (void) setScriptDebugDelegate:(id)delegate;
83 - (void) _setFormDelegate:(id)delegate;
84 - (void) _setUIKitDelegate:(id)delegate;
85 - (void) setWebMailDelegate:(id)delegate;
86 - (void) _setLayoutInterval:(float)interval;
90 #define _forever for (;;)
92 _disused static unsigned trace_;
94 #define _trace() do { \
95 NSLog(@"_trace(%u)@%s:%u[%s](%p)\n", \
96 trace_++, __FILE__, __LINE__, __FUNCTION__, pthread_self() \
100 #define _assert(test) do \
102 fprintf(stderr, "_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \
107 #define _syscall(expr) \
108 do if ((long) (expr) != -1) \
110 else switch (errno) { \
117 @protocol CydgetController
118 - (NSDictionary *) currentConfiguration;
121 static Class $CydgetController(objc_getClass("CydgetController"));
122 static Class $UIFormAssistant(objc_getClass("UIFormAssistant"));
123 //static Class $SBStatusBarController(objc_getClass("SBStatusBarController"));
125 static Class $UIWebBrowserView;
126 static bool Wildcat_, iOS4;
128 @interface NSString (UIKit)
129 - (NSString *) stringByAddingPercentEscapes;
132 @implementation UIWebDocumentView (WebCycript)
134 - (void) _setScrollerOffset:(CGPoint)offset {
135 UIScroller *scroller([self _scroller]);
137 CGSize size([scroller contentSize]);
138 CGSize bounds([scroller bounds].size);
141 max.x = size.width - bounds.width;
142 max.y = size.height - bounds.height;
150 offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
151 offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
153 [scroller setOffset:offset];
158 /* Perl-Compatible RegEx {{{ */
168 Pcre(const char *regex, int options = 0) :
173 code_ = pcre_compile(regex, options, &error, &offset, NULL);
176 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** Pcre(,): [%u] %s", offset, error] userInfo:nil];
178 pcre_fullinfo(code_, study_, PCRE_INFO_CAPTURECOUNT, &capture_);
179 matches_ = new int[(capture_ + 1) * 3];
187 NSString *operator [](size_t match) {
188 return [[[NSString alloc] initWithBytes:(data_ + matches_[match * 2]) length:(matches_[match * 2 + 1] - matches_[match * 2]) encoding:NSUTF8StringEncoding] autorelease];
191 bool operator ()(NSString *data) {
192 // XXX: length is for characters, not for bytes
193 return operator ()([data UTF8String], [data length]);
196 bool operator ()(const char *data, size_t size) {
198 return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
202 /* WebCycript Delegate {{{ */
203 @interface WebCycriptDelegate : NSObject {
204 _transient volatile id delegate_;
207 - (void) setDelegate:(id)delegate;
208 - (id) initWithDelegate:(id)delegate;
211 @implementation WebCycriptDelegate
213 - (void) setDelegate:(id)delegate {
214 delegate_ = delegate;
217 - (id) initWithDelegate:(id)delegate {
218 delegate_ = delegate;
222 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
223 if (delegate_ != nil)
224 return [delegate_ webView:sender didClearWindowObject:window forFrame:frame];
227 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
228 if (delegate_ != nil)
229 return [delegate_ webView:sender didCommitLoadForFrame:frame];
232 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
233 if (delegate_ != nil)
234 return [delegate_ webView:sender didFailLoadWithError:error forFrame:frame];
237 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
238 if (delegate_ != nil)
239 return [delegate_ webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
242 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
243 if (delegate_ != nil)
244 return [delegate_ webView:sender didFinishLoadForFrame:frame];
247 /*- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
248 if (delegate_ != nil)
249 return [delegate_ webView:sender didReceiveTitle:title forFrame:frame];
252 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
253 if (delegate_ != nil)
254 return [delegate_ webView:sender didStartProvisionalLoadForFrame:frame];
257 /*- (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
258 if (delegate_ != nil)
259 return [delegate_ webView:sender resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
262 /*- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
263 if (delegate_ != nil)
264 return [delegate_ webView:sender resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:source];
268 - (IMP) methodForSelector:(SEL)sel {
269 if (IMP method = [super methodForSelector:sel])
271 fprintf(stderr, "methodForSelector:[%s] == NULL\n", sel_getName(sel));
275 - (BOOL) respondsToSelector:(SEL)sel {
276 if ([super respondsToSelector:sel])
278 // XXX: WebThreadCreateNSInvocation returns nil
279 //fprintf(stderr, "[%s]R?%s\n", class_getName(self->isa), sel_getName(sel));
280 return delegate_ == nil ? NO : [delegate_ respondsToSelector:sel];
283 - (NSMethodSignature *) methodSignatureForSelector:(SEL)sel {
284 if (NSMethodSignature *method = [super methodSignatureForSelector:sel])
286 //fprintf(stderr, "[%s]S?%s\n", class_getName(self->isa), sel_getName(sel));
287 if (delegate_ != nil)
288 if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel])
290 // XXX: I fucking hate Apple so very very bad
291 return [NSMethodSignature signatureWithObjCTypes:"v@:"];
294 - (void) forwardInvocation:(NSInvocation *)inv {
295 SEL sel = [inv selector];
296 if (delegate_ != nil && [delegate_ respondsToSelector:sel])
297 [inv invokeWithTarget:delegate_];
303 @interface WebCydgetLockScreenView : UIView {
304 WebCycriptDelegate *indirect_;
305 UIProgressIndicator *indicator_;
306 UIScroller *scroller_;
307 UIWebDocumentView *document_;
318 NSMutableSet *loading_;
322 //UIKeyboard *keyboard_;
327 @implementation WebCydgetLockScreenView
329 //#include "UICaboodle/UCInternal.h"
334 WebView *webview([document_ webView]);
335 [webview setFrameLoadDelegate:nil];
336 [webview setResourceLoadDelegate:nil];
337 [webview setUIDelegate:nil];
338 [webview setScriptDebugDelegate:nil];
339 [webview setPolicyDelegate:nil];
341 /* XXX: these are set by UIWebDocumentView
342 [webview setDownloadDelegate:nil];
343 [webview _setFormDelegate:nil];
344 [webview _setUIKitDelegate:nil];
345 [webview setEditingDelegate:nil];*/
347 /* XXX: no one sets this, ever
348 [webview setWebMailDelegate:nil];*/
350 [document_ setDelegate:nil];
351 [document_ setGestureDelegate:nil];
353 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
354 [document_ setFormEditingDelegate:nil];
356 [document_ setInteractionDelegate:nil];
358 [indirect_ setDelegate:nil];
367 [scroller_ setDelegate:nil];
372 //[keyboard_ release];
375 [indicator_ release];
380 + (float) defaultWidth {
384 - (void) webView:(WebView *)sender didReceiveMessage:(NSDictionary *)dictionary {
385 #if LogBrowser || ForSaurik
386 NSLog(@"Console:%@\n", [dictionary description]);
388 if ([document_ respondsToSelector:@selector(webView:didReceiveMessage:)])
389 [document_ webView:sender didReceiveMessage:dictionary];
392 - (void) webView:(id)sender willCloseFrame:(id)frame {
393 if ([document_ respondsToSelector:@selector(webView:willCloseFrame:)])
394 [document_ webView:sender willCloseFrame:frame];
397 - (void) webView:(id)sender didFinishDocumentLoadForFrame:(id)frame {
398 if ([document_ respondsToSelector:@selector(webView:didFinishDocumentLoadForFrame:)])
399 [document_ webView:sender didFinishDocumentLoadForFrame:frame];
402 - (void) webView:(id)sender didFirstLayoutInFrame:(id)frame {
403 if ([document_ respondsToSelector:@selector(webView:didFirstLayoutInFrame:)])
404 [document_ webView:sender didFirstLayoutInFrame:frame];
407 - (void) webViewFormEditedStatusHasChanged:(id)changed {
408 if ([document_ respondsToSelector:@selector(webViewFormEditedStatusHasChanged:)])
409 [document_ webViewFormEditedStatusHasChanged:changed];
412 - (void) webView:(id)sender formStateDidFocusNode:(id)formState {
413 if ([document_ respondsToSelector:@selector(webView:formStateDidFocusNode:)])
414 [document_ webView:sender formStateDidFocusNode:formState];
417 - (void) webView:(id)sender formStateDidBlurNode:(id)formState {
418 if ([document_ respondsToSelector:@selector(webView:formStateDidBlurNode:)])
419 [document_ webView:sender formStateDidBlurNode:formState];
422 - (void) webViewDidLayout:(id)sender {
423 [document_ webViewDidLayout:sender];
426 - (void) webView:(id)sender didFirstVisuallyNonEmptyLayoutInFrame:(id)frame {
427 [document_ webView:sender didFirstVisuallyNonEmptyLayoutInFrame:frame];
430 - (void) webView:(id)sender saveStateToHistoryItem:(id)item forFrame:(id)frame {
431 [document_ webView:sender saveStateToHistoryItem:item forFrame:frame];
434 - (void) webView:(id)sender restoreStateFromHistoryItem:(id)item forFrame:(id)frame force:(BOOL)force {
435 [document_ webView:sender restoreStateFromHistoryItem:item forFrame:frame force:force];
438 - (void) webView:(id)sender attachRootLayer:(id)layer {
439 [document_ webView:sender attachRootLayer:layer];
442 - (id) webView:(id)sender plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package {
443 return [document_ webView:sender plugInViewWithArguments:arguments fromPlugInPackage:package];
446 - (void) webView:(id)sender willShowFullScreenForPlugInView:(id)view {
447 [document_ webView:sender willShowFullScreenForPlugInView:view];
450 - (void) webView:(id)sender didHideFullScreenForPlugInView:(id)view {
451 [document_ webView:sender didHideFullScreenForPlugInView:view];
454 - (void) webView:(id)sender willAddPlugInView:(id)view {
455 [document_ webView:sender willAddPlugInView:view];
458 - (void) webView:(id)sender didObserveDeferredContentChange:(int)change forFrame:(id)frame {
459 [document_ webView:sender didObserveDeferredContentChange:change forFrame:frame];
462 - (void) webViewDidPreventDefaultForEvent:(id)sender {
463 [document_ webViewDidPreventDefaultForEvent:sender];
466 - (void) _setTileDrawingEnabled:(BOOL)enabled {
467 //[document_ setTileDrawingEnabled:enabled];
470 - (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
471 [self _setTileDrawingEnabled:NO];
474 - (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
475 [self _setTileDrawingEnabled:YES];
476 [document_ redrawScaledDocument];
479 - (void) setViewportWidth:(float)width {
480 width_ = width != 0 ? width : [[self class] defaultWidth];
481 [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
484 - (void) scrollerWillStartDragging:(UIScroller *)scroller {
485 [self _setTileDrawingEnabled:NO];
488 - (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
489 [self _setTileDrawingEnabled:YES];
492 - (void) scrollerDidEndDragging:(UIScroller *)scroller {
493 [self _setTileDrawingEnabled:YES];
496 - (void) loadRequest:(NSURLRequest *)request {
500 [document_ loadRequest:request];
504 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
505 [self loadRequest:[NSURLRequest
512 - (void) loadURL:(NSURL *)url {
513 [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
517 CGRect frame = {{0, 0}, {320, 480}};
518 frame.size.height -= 20; //[[[$SBStatusBarController sharedStatusBarController] statusBarView] frame].size.height;
520 if ((self = [super initWithFrame:frame]) != nil) {
521 loading_ = [[NSMutableSet alloc] initWithCapacity:3];
523 struct CGRect bounds([self bounds]);
525 scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
526 [self addSubview:scroller_];
528 [scroller_ setFixedBackgroundPattern:YES];
529 [scroller_ setBackgroundColor:[UIColor blackColor]];
531 [scroller_ setScrollingEnabled:YES];
532 [scroller_ setClipsSubviews:YES];
535 [scroller_ setAllowsRubberBanding:YES];
537 [scroller_ setDelegate:self];
538 [scroller_ setBounces:YES];
541 [scroller_ setScrollHysteresis:8];
542 [scroller_ setThumbDetectionEnabled:NO];
543 [scroller_ setDirectionalScrolling:YES];
544 //[scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
545 [scroller_ setEventMode:YES];
549 UIScrollView *scroller((UIScrollView *)scroller_);
550 //[scroller setDirectionalLockEnabled:NO];
551 [scroller setDelaysContentTouches:NO];
552 //[scroller setScrollsToTop:NO];
553 //[scroller setCanCancelContentTouches:NO];
556 [scroller_ setShowBackgroundShadow:NO]; /* YES */
557 //[scroller_ setAllowsRubberBanding:YES]; /* Vertical */
560 [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
562 CGRect rect([scroller_ bounds]);
563 //rect.size.height = 0;
567 document_ = [[$UIWebBrowserView alloc] initWithFrame:rect];
568 WebView *webview([document_ webView]);
570 [document_ setBackgroundColor:[UIColor blackColor]];
571 if ([document_ respondsToSelector:@selector(setDrawsBackground:)])
572 [document_ setDrawsBackground:NO];
573 [webview setDrawsBackground:NO];
575 [webview setPreferencesIdentifier:@"WebCycript"];
577 [document_ setTileSize:CGSizeMake(rect.size.width, 500)];
579 if ([document_ respondsToSelector:@selector(enableReachability)])
580 [document_ enableReachability];
581 if ([document_ respondsToSelector:@selector(setAllowsMessaging:)])
582 [document_ setAllowsMessaging:YES];
583 if ([document_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
584 [document_ useSelectionAssistantWithMode:0];
586 [document_ setTilingEnabled:YES];
587 [document_ setDrawsGrid:NO];
588 [document_ setLogsTilingChanges:NO];
589 [document_ setTileMinificationFilter:kCAFilterNearest];
591 if ([document_ respondsToSelector:@selector(setDataDetectorTypes:)])
592 /* XXX: abstractify */
593 [document_ setDataDetectorTypes:0x80000000];
595 [document_ setDetectsPhoneNumbers:NO];
597 [document_ setAutoresizes:YES];
599 [document_ setMinimumScale:0.25f forDocumentTypes:0x10];
600 [document_ setMaximumScale:5.00f forDocumentTypes:0x10];
601 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
602 //[document_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
604 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
606 [document_ setMinimumScale:1.00f forDocumentTypes:0x8];
607 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
608 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
610 [document_ _setDocumentType:0x4];
612 if ([document_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
613 [document_ setZoomsFocusedFormControl:YES];
614 [document_ setContentsPosition:7];
615 [document_ setEnabledGestures:0xa];
616 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
617 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
619 [document_ setSmoothsFonts:YES];
620 [document_ setAllowsImageSheet:YES];
621 [webview _setUsesLoaderCache:YES];
623 [webview setGroupName:@"CydgetGroup"];
625 WebPreferences *preferences([webview preferences]);
627 if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
628 [webview _setLayoutInterval:0];
630 [preferences _setLayoutInterval:0];
632 [self setViewportWidth:0];
634 [document_ setDelegate:self];
635 [document_ setGestureDelegate:self];
637 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
638 [document_ setFormEditingDelegate:self];
639 [document_ setInteractionDelegate:self];
641 [scroller_ addSubview:document_];
643 //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
645 indirect_ = [[WebCycriptDelegate alloc] initWithDelegate:self];
647 [webview setFrameLoadDelegate:indirect_];
648 [webview setPolicyDelegate:indirect_];
649 [webview setResourceLoadDelegate:indirect_];
650 [webview setUIDelegate:indirect_];
652 /* XXX: do not turn this on under penalty of extreme pain */
653 [webview setScriptDebugDelegate:nil];
657 CGSize indsize([UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite]);
658 indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 12, indsize.width, indsize.height)];
659 [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
661 [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
662 [scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
664 NSDictionary *configuration([$CydgetController currentConfiguration]);
666 cycript_ = [configuration objectForKey:@"CycriptURLs"];
668 scrollable_ = [[configuration objectForKey:@"Scrollable"] boolValue];
669 [scroller_ setScrollingEnabled:scrollable_];
671 NSString *homepage([configuration objectForKey:@"Homepage"]);
672 [self loadURL:[NSURL URLWithString:homepage]];
674 /*[UIKeyboard initImplementationNow];
675 CGSize keysize = [UIKeyboard defaultSize];
676 CGRect keyrect = {{0, [self bounds].size.height - 100}, keysize};
677 keyboard_ = [[UIKeyboard alloc] initWithFrame:keyrect];
678 [self addSubview:keyboard_];
680 [self addSubview:[[UITextView alloc] initWithFrame:CGRectMake(200, 0, 100, 100)]];
681 [self addSubview:[[UITextView alloc] initWithFrame:CGRectMake(200, 150, 100, 100)]];
682 [self addSubview:[[UITextView alloc] initWithFrame:CGRectMake(200, 300, 100, 100)]];*/
686 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
689 UIActionSheet *sheet = [[[UIActionSheet alloc]
691 buttons:[NSArray arrayWithObjects:@"OK", nil]
697 [sheet setBodyText:message];
698 [sheet popupAlertAnimated:YES];
701 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
704 UIActionSheet *sheet = [[[UIActionSheet alloc]
706 buttons:[NSArray arrayWithObjects:@"OK", @"CANCEL", nil]
712 [sheet setNumberOfRows:1];
713 [sheet setBodyText:message];
714 [sheet popupAlertAnimated:YES];
716 NSRunLoop *loop([NSRunLoop currentRunLoop]);
717 NSDate *future([NSDate distantFuture]);
719 while (confirm_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
721 NSNumber *confirm([confirm_ autorelease]);
725 return [confirm boolValue];
728 /* XXX: WebThreadLock? */
729 - (void) _fixScroller:(CGRect)bounds {
731 if (!editing_ || $UIFormAssistant == nil)
734 UIFormAssistant *assistant([$UIFormAssistant sharedFormAssistant]);
735 CGRect peripheral([assistant peripheralFrame]);
736 extra = peripheral.size.height;
739 CGRect subrect([scroller_ frame]);
740 subrect.size.height -= [TPBottomLockBar defaultHeight];
741 subrect.size.height -= extra;
743 if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
744 [scroller_ setScrollerIndicatorSubrect:subrect];
746 [document_ setValue:[NSValue valueWithSize:NSMakeSize(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
749 size.height += extra;
750 size.height += [TPBottomLockBar defaultHeight];
751 [scroller_ setContentSize:size];
753 if ([scroller_ respondsToSelector:@selector(releaseRubberBandIfNecessary)])
754 [scroller_ releaseRubberBandIfNecessary];
757 - (void) fixScroller {
758 CGRect bounds([document_ documentBounds]);
759 [self _fixScroller:bounds];
762 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
764 [self _fixScroller:frame];
767 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
768 [self view:sender didSetFrame:frame];
771 - (void) formAssistant:(id)sender didBeginEditingFormNode:(id)node {
774 - (void) formAssistant:(id)sender didEndEditingFormNode:(id)node {
778 - (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
782 - (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
786 - (void) webViewDidEndEditingFormElements:(WebView *)sender {
791 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
793 if (NSString *href = [[[[frame dataSource] request] URL] absoluteString])
794 if (Pcre([cycript_ UTF8String], 0 /*XXX:PCRE_UTF8*/)(href))
795 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
796 if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
797 WebView *webview([document_ webView]);
798 WebFrame *frame([webview mainFrame]);
799 JSGlobalContextRef context([frame globalContext]);
800 CYSetupContext(context);
805 return [loading_ count] != 0;
808 - (void) reloadButtons {
809 if ([self isLoading]) {
810 [UIApp setNetworkActivityIndicatorVisible:YES];
811 [indicator_ startAnimation];
813 [UIApp setNetworkActivityIndicatorVisible:NO];
814 [indicator_ stopAnimation];
818 - (void) _finishLoading {
819 size_t count([loading_ count]);
821 [self autorelease];*/
822 if (reloading_ || count != 0)
824 [self reloadButtons];
827 - (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
828 return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
831 - (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
832 return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
835 - (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
836 return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
839 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
840 return [document_ webView:sender didCommitLoadForFrame:frame];
843 - (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
844 return [document_ webView:sender didReceiveDocTypeForFrame:frame];
847 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
848 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
849 [self _finishLoading];
850 return [document_ webView:sender didFinishLoadForFrame:frame];
853 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
854 /*if ([loading_ count] == 0)
856 [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
858 if ([frame parentFrame] == nil) {
859 [document_ resignFirstResponder];
864 CGRect webrect = [scroller_ bounds];
865 webrect.size.height = 1;
866 [document_ setFrame:webrect];
869 if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
870 [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
872 [scroller_ scrollRectToVisible:CGRectZero animated:NO];
874 if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
875 [scroller_ setZoomScale:1 duration:0];
876 else if ([scroller_ respondsToSelector:@selector(_setZoomScale:duration:)])
877 [scroller_ _setZoomScale:1 duration:0];
878 /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
879 [scroller_ setZoomScale:1 animated:NO];*/
882 CGRect webrect = [scroller_ bounds];
883 webrect.size.height = 1;
884 [document_ setFrame:webrect];
888 [self reloadButtons];
891 - (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
892 /*if ([frame parentFrame] == nil)
893 [self autorelease];*/
895 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
896 [self _finishLoading];
901 if ([frame parentFrame] == nil) {
902 [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
903 [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
904 [[error localizedDescription] stringByAddingPercentEscapes]
911 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
912 [self _didFailWithError:error forFrame:frame];
913 if ([document_ respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
914 [document_ webView:sender didFailLoadWithError:error forFrame:frame];
917 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
918 [self _didFailWithError:error forFrame:frame];
921 - (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
922 NSLog(@"Console:%@\n", [dictionary description]);
927 @interface WebCycriptLockScreenController : SBAwayViewPluginController {
938 // String Helpers {{{
939 static const UChar *(*_ZNK7WebCore6String10charactersEv)(const WebCore::String *);
940 static const UChar *(*_ZN7WebCore6String29charactersWithNullTerminationEv)(const WebCore::String *);
941 static unsigned (*_ZNK7WebCore6String6lengthEv)(const WebCore::String *);
943 static bool StringGet(const WebCore::String &string, const UChar *&data, size_t &length) {
946 if (_ZNK7WebCore6String10charactersEv != NULL) {
947 data = (*_ZNK7WebCore6String10charactersEv)(&string);
949 } else if (_ZN7WebCore6String29charactersWithNullTerminationEv != NULL) {
950 data = (*_ZN7WebCore6String29charactersWithNullTerminationEv)(&string);
954 if (_ZNK7WebCore6String6lengthEv != NULL)
955 length = (*_ZNK7WebCore6String6lengthEv)(&string);
957 for (length = 0; data[length] != 0; ++length);
963 static bool StringEquals(const WebCore::String &string, const char *value) {
966 if (!StringGet(string, data, size))
969 size_t length(strlen(value));
973 for (size_t index(0); index != length; ++index)
974 if (data[index] != value[index])
981 static bool cycript_;
983 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
985 if (!StringEquals(mime, "text/cycript")) {
987 return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
991 static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
999 // Script Compiler {{{
1000 static void Log(const WebCore::String &string) {
1004 if (!StringGet(string, data, length))
1007 UChar terminated[length + 1];
1008 terminated[length] = 0;
1009 memcpy(terminated, data, length * 2);
1010 NSLog(@"wtf %p:%zu:%S:", &string, length, terminated);
1014 static void Cycriptify(apr_pool_t *pool, const uint16_t *&data, size_t &size) {
1017 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
1018 if (void (*CydgetPoolParse)(apr_pool_t *, const uint16_t **, size_t *) = reinterpret_cast<void (*)(apr_pool_t *, const uint16_t **, size_t *)>(dlsym(handle, "CydgetPoolParse")))
1019 CydgetPoolParse(pool, &data, &size);
1022 static void (*_ZN7WebCore6String6appendEPKtj)(WebCore::String *, const UChar *, unsigned);
1023 static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
1025 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
1032 if (!StringGet(source, data, length)) {
1037 size_t size(length);
1040 apr_pool_create(&pool, NULL);
1042 Cycriptify(pool, data, size);
1044 WebCore::String &script(const_cast<WebCore::String &>(source));
1046 _ZN7WebCore6String8truncateEj(&script, 0);
1047 _ZN7WebCore6String6appendEPKtj(&script, data, size);
1052 apr_pool_destroy(pool);
1058 extern "C" void *_ZN3JSC7UString3Rep14nullBaseStringE __attribute__((__weak_import__));
1059 extern "C" void *_ZN3JSC7UString3Rep7destroyEv __attribute__((__weak_import__));
1060 extern "C" void *_ZN3JSC7UStringC1EPKti __attribute__((__weak_import__));
1061 extern "C" void *_ZN3JSC7UStringC1EPKc __attribute__((__weak_import__));
1062 extern "C" void *_ZNK3JSC7UString6substrEii __attribute__((__weak_import__));
1063 extern "C" void *_ZN3WTF10fastMallocEm __attribute__((__weak_import__));
1064 extern "C" void WTFReportAssertionFailure(const char *, int, const char *, const char *) __attribute__((__weak_import__));
1065 extern "C" void *_ZN3WTF8fastFreeEPv __attribute__((__weak_import__));
1069 &_ZN3JSC7UString3Rep14nullBaseStringE == NULL ||
1070 &_ZN3JSC7UString3Rep7destroyEv == NULL ||
1071 &_ZN3JSC7UStringC1EPKti == NULL ||
1072 &_ZN3JSC7UStringC1EPKc == NULL ||
1073 &_ZNK3JSC7UString6substrEii == NULL ||
1074 &_ZN3WTF10fastMallocEm == NULL ||
1075 &WTFReportAssertionFailure == NULL ||
1076 &_ZN3WTF8fastFreeEPv == NULL ||
1080 static WebCore::String *string;
1083 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, void *_this, const WebCore::String &string, State state, const WebCore::String &url, int line) {
1086 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line);
1090 MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
1092 JSC::SourceCode *source(*_this);
1093 const uint16_t *data(source->data());
1094 size_t size(source->length());
1097 apr_pool_create(&pool, NULL);
1099 Cycriptify(pool, data, size);
1100 source->~SourceCode();
1101 // XXX: I actually don't have the original URL here: pants
1102 new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
1104 apr_pool_destroy(pool);
1108 return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
1112 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) {
1115 return __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line);
1119 MSHook(const WebCore::String &, _ZN7WebCore12CachedScript6scriptEv, void *_this) {
1121 const WebCore::String &script(__ZN7WebCore12CachedScript6scriptEv(_this));
1122 string = const_cast<WebCore::String *>(&script);
1128 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, void *_this, void *source, State state) {
1130 if (string != NULL) {
1132 Cycriptify(*string, reinterpret_cast<int *>(source) + 3);
1134 Cycriptify(*string);
1137 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE(_this, source, state);
1140 /* Cydget:// Protocol {{{ */
1141 @interface CydgetURLProtocol : NSURLProtocol {
1146 @implementation CydgetURLProtocol
1148 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
1149 NSURL *url([request URL]);
1152 NSString *scheme([[url scheme] lowercaseString]);
1153 if (scheme == nil || ![scheme isEqualToString:@"cydget"])
1158 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
1162 - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
1163 id<NSURLProtocolClient> client([self client]);
1165 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
1167 NSData *data(UIImagePNGRepresentation(icon));
1169 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
1170 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
1171 [client URLProtocol:self didLoadData:data];
1172 [client URLProtocolDidFinishLoading:self];
1176 - (void) startLoading {
1177 id<NSURLProtocolClient> client([self client]);
1178 NSURLRequest *request([self request]);
1180 NSURL *url([request URL]);
1181 NSString *href([url absoluteString]);
1183 NSString *path([href substringFromIndex:9]);
1184 NSRange slash([path rangeOfString:@"/"]);
1187 if (slash.location == NSNotFound) {
1191 command = [path substringToIndex:slash.location];
1192 path = [path substringFromIndex:(slash.location + 1)];
1195 if ([command isEqualToString:@"_UIImageWithName"]) {
1198 path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
1199 UIImage *icon(_UIImageWithName(path));
1200 [self _returnPNGWithImage:icon forRequest:request];
1202 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
1206 - (void) stopLoading {
1211 /* Cydget-CGI:// Protocol {{{ */
1212 @interface CydgetCGIURLProtocol : NSURLProtocol {
1214 CFHTTPMessageRef http_;
1215 NSFileHandle *handle_;
1220 @implementation CydgetCGIURLProtocol
1222 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
1223 NSURL *url([request URL]);
1226 NSString *scheme([[url scheme] lowercaseString]);
1227 if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
1232 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
1236 - (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)response client:(id<NSURLProtocolClient>)client {
1237 if ((self = [super initWithRequest:request cachedResponse:response client:client]) != nil) {
1242 - (void) startLoading {
1243 id<NSURLProtocolClient> client([self client]);
1244 NSURLRequest *request([self request]);
1245 NSURL *url([request URL]);
1247 NSString *path([url path]);
1249 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
1253 NSFileManager *manager([NSFileManager defaultManager]);
1254 if (![manager fileExistsAtPath:path]) {
1255 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
1260 _assert(pipe(fds) != -1);
1262 _assert(pid_ == -1);
1265 _assert(close(fds[0]) != -1);
1266 _assert(close(fds[1]) != -1);
1267 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
1272 const char *script([path UTF8String]);
1274 setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
1275 setenv("SCRIPT_FILENAME", script, true);
1276 NSString *query([url query]);
1278 setenv("QUERY_STRING", [query UTF8String], true);
1280 _assert(dup2(fds[1], 1) != -1);
1281 _assert(close(fds[0]) != -1);
1282 _assert(close(fds[1]) != -1);
1284 execl(script, script, NULL);
1289 _assert(close(fds[1]) != -1);
1291 _assert(http_ == NULL);
1292 http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
1293 CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
1295 _assert(handle_ == nil);
1296 handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
1298 [[NSNotificationCenter defaultCenter]
1300 selector:@selector(onRead:)
1301 name:@"NSFileHandleReadCompletionNotification"
1305 [handle_ readInBackgroundAndNotify];
1308 - (void) onRead:(NSNotification *)notification {
1309 NSFileHandle *handle([notification object]);
1311 NSData *data([[notification userInfo] objectForKey:NSFileHandleNotificationDataItem]);
1313 if (size_t length = [data length]) {
1314 CFHTTPMessageAppendBytes(http_, reinterpret_cast<const UInt8 *>([data bytes]), length);
1315 [handle readInBackgroundAndNotify];
1317 id<NSURLProtocolClient> client([self client]);
1319 CFStringRef mime(CFHTTPMessageCopyHeaderFieldValue(http_, CFSTR("Content-type")));
1321 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:nil]];
1323 NSURLRequest *request([self request]);
1325 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:(NSString *)mime expectedContentLength:-1 textEncodingName:nil] autorelease]);
1328 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
1330 CFDataRef body(CFHTTPMessageCopyBody(http_));
1331 [client URLProtocol:self didLoadData:(NSData *)body];
1334 [client URLProtocolDidFinishLoading:self];
1342 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
1344 - (void) stopLoading_ {
1345 [[NSNotificationCenter defaultCenter] removeObserver:self];
1347 if (handle_ != nil) {
1353 kill(pid_, SIGTERM);
1355 _syscall(waitpid(pid_, &status, 0));
1360 - (void) stopLoading {
1362 performSelectorOnMainThread:@selector(stopLoading_)
1371 template <typename Type_>
1372 static void nlset(Type_ &function, struct nlist *nl, size_t index) {
1373 struct nlist &name(nl[index]);
1374 uintptr_t value(name.n_value);
1375 if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
1376 value |= 0x00000001;
1377 function = reinterpret_cast<Type_>(value);
1380 template <typename Type_>
1381 static void dlset(Type_ &function, const char *name) {
1382 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
1385 template <typename Type_>
1386 static void msset_(Type_ &function, const char *name, MSImageRef handle) {
1387 function = reinterpret_cast<Type_>(MSFindSymbol(handle, name));
1390 #define msset(function, handle) \
1391 msset_(function, "_" #function, handle)
1393 @implementation WebCycriptLockScreenController
1395 + (void) initialize {
1396 iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
1398 $UIWebBrowserView = objc_getClass("UIWebBrowserView");
1399 if ($UIWebBrowserView == nil) {
1401 $UIWebBrowserView = objc_getClass("UIWebDocumentView");
1407 size_t size(sizeof(maxproc));
1408 if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
1409 NSLog(@"sysctlbyname(\"kern.maxproc\", ?)");
1410 else if (maxproc < 72) {
1412 if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1)
1413 NSLog(@"sysctlbyname(\"kern.maxproc\", #)");
1418 [NSURLProtocol registerClass:[CydgetURLProtocol class]];
1419 [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
1422 void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
1423 dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
1424 if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
1425 MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
1429 memset(nl, 0, sizeof(nl));
1431 nl[0].n_un.n_name = (char *) "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE";
1433 nl[1].n_un.n_name = (char *) "__ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi";
1435 nl[2].n_un.n_name = (char *) "__ZN7WebCore12CachedScript6scriptEv";
1436 nl[3].n_un.n_name = (char *) "__ZNK7WebCore20StringSourceProvider6sourceEv";
1438 nl[4].n_un.n_name = (char *) "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i";
1439 nl[5].n_un.n_name = (char *) "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE";
1441 nl[6].n_un.n_name = (char *) "__ZN7WebCore6String6appendEPKtj";
1442 nl[7].n_un.n_name = (char *) "__ZN7WebCore6String8truncateEj";
1444 nlist("/System/Library/PrivateFrameworks/WebCore.framework/WebCore", nl);
1446 bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &);
1447 nlset(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, nl, 0);
1448 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL)
1449 MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
1451 void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int);
1452 nlset(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, nl, 1);
1453 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL)
1454 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
1457 const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *);
1458 nlset(_ZN7WebCore12CachedScript6scriptEv, nl, 2);
1459 if (_ZN7WebCore12CachedScript6scriptEv != NULL)
1460 MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
1463 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i)(void *, const WebCore::String &, State, const WebCore::String &, int);
1464 nlset(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, nl, 4);
1465 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL)
1466 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i));
1469 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, void *, State);
1470 nlset(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, nl, 5);
1471 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
1472 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
1475 nlset(_ZN7WebCore6String6appendEPKtj, nl, 6);
1476 nlset(_ZN7WebCore6String8truncateEj, nl, 7);
1478 MSImageRef JavaScriptCore(MSGetImageByName("/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore"));
1479 //MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
1481 if (_ZN7WebCore6String6appendEPKtj == NULL)
1482 msset(_ZN7WebCore6String6appendEPKtj, JavaScriptCore);
1484 if (_ZN7WebCore6String8truncateEj == NULL)
1485 msset(_ZN7WebCore6String8truncateEj, JavaScriptCore);
1487 msset(_ZNK7WebCore6String10charactersEv, JavaScriptCore);
1488 msset(_ZN7WebCore6String29charactersWithNullTerminationEv, JavaScriptCore);
1489 msset(_ZNK7WebCore6String6lengthEv, JavaScriptCore);
1492 + (id) rootViewController {
1493 return [[[self alloc] init] autorelease];
1497 [self setView:[[[WebCydgetLockScreenView alloc] init] autorelease]];