1 /* Cydget - open-source AwayView plugin multiplexer
2 * Copyright (C) 2009-2014 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cydia is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cydia is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
22 #include <CydiaSubstrate/CydiaSubstrate.h>
23 #include <UIKit/UIKit.h>
25 #include <sys/sysctl.h>
28 #include <SpringBoardUI/SBAwayViewPluginController.h>
30 #include <WebKit/WebFrame.h>
31 #include <WebKit/WebView.h>
32 #include <WebKit/WebPreferences-WebPrivate.h>
34 #include "yieldToSelector.h"
37 #include <unicode/uregex.h>
43 #define _forever for (;;)
45 _disused static unsigned trace_;
47 #define _trace() do { \
48 NSLog(@"_trace(%u)@%s:%u[%s](%p)\n", \
49 trace_++, __FILE__, __LINE__, __FUNCTION__, pthread_self() \
53 #define _assert(test) do \
55 NSLog(@"_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \
60 #define _syscall(expr) \
61 do if ((long) (expr) != -1) \
63 else switch (errno) { \
70 extern "C" UIImage *_UIImageWithName(NSString *name);
72 typedef uint16_t UChar;
74 @interface TPBottomLockBar
75 - (CGFloat) defaultHeight;
78 @interface UIApplication (Apple)
79 - (void) applicationOpenURL:(NSURL *)url;
82 @interface UIScroller : UIView
83 - (CGSize) contentSize;
84 - (void) setDirectionalScrolling:(BOOL)directional;
85 - (void) setOffset:(CGPoint)offset;
86 - (void) setScrollDecelerationFactor:(CGFloat)factor;
87 - (void) setScrollHysteresis:(CGFloat)hysteresis;
88 - (void) setThumbDetectionEnabled:(BOOL)enabled;
91 @interface UIWebDocumentView : UIView
92 - (CGRect) documentBounds;
93 - (void) enableReachability;
94 - (void) loadRequest:(NSURLRequest *)request;
95 - (void) redrawScaledDocument;
96 - (void) setAllowsImageSheet:(BOOL)allows;
97 - (void) setAllowsMessaging:(BOOL)allows;
98 - (void) setAutoresizes:(BOOL)autoresizes;
99 - (void) setContentsPosition:(NSInteger)position;
100 - (void) setDrawsBackground:(BOOL)draws;
101 - (void) _setDocumentType:(NSInteger)type;
102 - (void) setDrawsGrid:(BOOL)draws;
103 - (void) setInitialScale:(float)scale forDocumentTypes:(NSInteger)types;
104 - (void) setLogsTilingChanges:(BOOL)logs;
105 - (void) setMinimumScale:(float)scale forDocumentTypes:(NSInteger)types;
106 - (void) setMinimumSize:(CGSize)size;
107 - (void) setMaximumScale:(float)scale forDocumentTypes:(NSInteger)tpyes;
108 - (void) setSmoothsFonts:(BOOL)smooths;
109 - (void) setTileMinificationFilter:(NSString *)filter;
110 - (void) setTileSize:(CGSize)size;
111 - (void) setTilingEnabled:(BOOL)enabled;
112 - (void) setViewportSize:(CGSize)size forDocumentTypes:(NSInteger)types;
113 - (void) setZoomsFocusedFormControl:(BOOL)zooms;
114 - (void) useSelectionAssistantWithMode:(NSInteger)mode;
115 - (WebView *) webView;
118 @interface UIView (Apple)
119 - (UIScroller *) _scroller;
120 - (void) setClipsSubviews:(BOOL)clips;
121 - (void) setEnabledGestures:(NSInteger)gestures;
122 - (void) setFixedBackgroundPattern:(BOOL)fixed;
123 - (void) setGestureDelegate:(id)delegate;
124 - (void) setNeedsDisplayOnBoundsChange:(BOOL)needs;
125 - (void) setValue:(NSValue *)value forGestureAttribute:(NSInteger)attribute;
126 - (void) setZoomScale:(float)scale duration:(double)duration;
127 - (void) _setZoomScale:(float)scale duration:(double)duration;
130 @interface SBLockScreenViewController : UIViewController
131 - (BOOL) isShowingMediaControls;
132 - (void) _setMediaControlsVisible:(BOOL)visible;
135 @interface SBLockScreenManager : NSObject
136 + (SBLockScreenManager *) sharedInstance;
137 - (SBLockScreenViewController *) lockScreenViewController;
140 @protocol CydgetController
141 - (NSDictionary *) currentConfiguration;
142 - (NSString *) currentPath;
145 static Class $CydgetController(objc_getClass("CydgetController"));
147 static bool iOS32, iOS4;
149 @interface NSString (UIKit)
150 - (NSString *) stringByAddingPercentEscapes;
153 @implementation UIWebDocumentView (WebCycript)
155 - (void) _setScrollerOffset:(CGPoint)offset {
156 UIScroller *scroller([self _scroller]);
158 CGSize size([scroller contentSize]);
159 CGSize bounds([scroller bounds].size);
162 max.x = size.width - bounds.width;
163 max.y = size.height - bounds.height;
171 offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
172 offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
174 [scroller setOffset:offset];
180 /* ICU Regular Expression {{{ */
183 URegularExpression *regex_;
186 RegEx(const char *regex) {
188 UErrorCode status(U_ZERO_ERROR);
189 regex_ = uregex_openC(regex, 0, &error, &status);
190 if (U_FAILURE(status))
191 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** RegEx(): [%u] %s", error.offset, u_errorName(status)] userInfo:nil];
195 uregex_close(regex_);
198 bool operator ()(NSString *string) {
199 return operator ()(reinterpret_cast<const uint16_t *>([string cStringUsingEncoding:NSUTF16StringEncoding]), [string length]);
202 bool operator ()(const UChar *data, size_t size) {
203 UErrorCode status(U_ZERO_ERROR);
204 uregex_setText(regex_, data, size, &status);
205 _assert(U_SUCCESS(status));
206 bool matches(uregex_matches(regex_, 0, &status));
207 _assert(U_SUCCESS(status));
213 /* Perl-Compatible RegEx {{{ */
223 RegEx(const char *regex) :
228 code_ = pcre_compile(regex, 0, &error, &offset, NULL);
231 @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** RegEx(): [%u] %s", offset, error] userInfo:nil];
233 pcre_fullinfo(code_, study_, PCRE_INFO_CAPTURECOUNT, &capture_);
234 matches_ = new int[(capture_ + 1) * 3];
242 bool operator ()(NSString *data) {
243 // XXX: length is for characters, not for bytes
244 return operator ()([data UTF8String], [data length]);
247 bool operator ()(const char *data, size_t size) {
249 return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
255 static float CYScrollViewDecelerationRateNormal;
257 @interface NSURL (Apple)
258 - (BOOL) isSpringboardHandledURL;
261 @interface UIScrollView (Apple)
262 - (void) setDecelerationRate:(CGFloat)value;
263 - (void) setScrollingEnabled:(BOOL)enabled;
264 - (void) setShowBackgroundShadow:(BOOL)show;
267 @interface UIWebView (Apple)
268 - (UIWebDocumentView *) _documentView;
269 - (void) setDataDetectorTypes:(NSInteger)types;
270 - (void) _setDrawInWebThread:(BOOL)draw;
271 - (UIScrollView *) _scrollView;
272 - (UIScroller *) _scroller;
273 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message;
274 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
277 @interface WebView (Apple)
278 - (void) _setLayoutInterval:(float)interval;
279 - (void) _setAllowsMessaging:(BOOL)allows;
280 - (void) setShouldUpdateWhileOffscreen:(BOOL)update;
283 @protocol CydgetWebViewDelegate <UIWebViewDelegate>
284 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
287 @class UIWebViewWebViewDelegate;
289 @interface CydgetWebView : UIWebView {
294 MSClassHook(UIApplication)
295 MSClassHook(SBLockScreenManager)
297 MSInstanceMessageHook1(void, UIApplication, openURL, NSURL *, url) {
298 [self applicationOpenURL:url];
301 @implementation NSURL (Cydget)
303 - (NSNumber *) cydget$isSpringboardHandledURL {
304 return [NSNumber numberWithBool:[self isSpringboardHandledURL]];
311 MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) {
312 if (![NSThread isMainThread])
315 return [[self cydget$yieldToSelector:@selector(cydget$isSpringboardHandledURL)] boolValue];
318 @implementation CydgetWebView
320 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
321 NSObject<CydgetWebViewDelegate> *delegate((NSObject<CydgetWebViewDelegate> *) [self delegate]);
322 if ([delegate respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
323 [delegate webView:view didClearWindowObject:window forFrame:frame];
324 if ([UIWebView instancesRespondToSelector:@selector(webView:didClearWindowObject:forFrame:)])
325 [super webView:view didClearWindowObject:window forFrame:frame];
328 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message {
329 NSLog(@"addMessageToConsole:%@", message);
331 if ([UIWebView instancesRespondToSelector:@selector(webView:addMessageToConsole:)])
332 [super webView:view addMessageToConsole:message];
337 @interface WebCydgetLockScreenView : UIView <UIWebViewDelegate> {
338 CydgetWebView *webview_;
339 UIScrollView *scroller_;
345 @implementation WebCydgetLockScreenView
347 //#include "UICaboodle/UCInternal.h"
350 [webview_ setDelegate:nil];
355 - (void) loadRequest:(NSURLRequest *)request {
356 [webview_ loadRequest:request];
359 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
360 [self loadRequest:[NSURLRequest
367 - (void) loadURL:(NSURL *)url {
368 [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
371 - (id) initWithURL:(NSURL *)url {
372 CGRect frame = [[UIScreen mainScreen] bounds];
373 if (kCFCoreFoundationVersionNumber < 800)
374 frame.size.height -= 20; //[[[$SBStatusBarController sharedStatusBarController] statusBarView] frame].size.height;
376 if ((self = [super initWithFrame:frame]) != nil) {
377 CGRect bounds([self bounds]);
378 if (kCFCoreFoundationVersionNumber < 800)
379 bounds.size.height -= [TPBottomLockBar defaultHeight];
381 webview_ = [[CydgetWebView alloc] initWithFrame:bounds];
382 [webview_ setDelegate:self];
383 [self addSubview:webview_];
385 if ([webview_ respondsToSelector:@selector(setDataDetectorTypes:)])
386 [webview_ setDataDetectorTypes:0x80000000];
388 [webview_ setDetectsPhoneNumbers:NO];
390 [webview_ setScalesPageToFit:YES];
392 if (kCFCoreFoundationVersionNumber < 478.61)
393 if ([webview_ respondsToSelector:@selector(_setDrawInWebThread:)])
394 [webview_ _setDrawInWebThread:NO];
396 UIWebDocumentView *document([webview_ _documentView]);
397 WebView *webview([document webView]);
398 WebPreferences *preferences([webview preferences]);
400 [document setTileSize:CGSizeMake(bounds.size.width, 500)];
402 [document setBackgroundColor:[UIColor clearColor]];
403 [document setDrawsBackground:NO];
405 [webview setPreferencesIdentifier:@"WebCycript"];
407 if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
408 [webview _setLayoutInterval:0];
410 [preferences _setLayoutInterval:0];
412 [preferences setCacheModel:WebCacheModelDocumentViewer];
413 [preferences setJavaScriptCanOpenWindowsAutomatically:YES];
414 [preferences setOfflineWebApplicationCacheEnabled:YES];
416 if ([webview respondsToSelector:@selector(setShouldUpdateWhileOffscreen:)])
417 [webview setShouldUpdateWhileOffscreen:NO];
419 if ([document respondsToSelector:@selector(setAllowsMessaging:)])
420 [document setAllowsMessaging:YES];
421 if ([webview respondsToSelector:@selector(_setAllowsMessaging:)])
422 [webview _setAllowsMessaging:YES];
424 if ([webview_ respondsToSelector:@selector(_scrollView)]) {
425 scroller_ = [webview_ _scrollView];
427 [scroller_ setDirectionalLockEnabled:YES];
428 [scroller_ setDecelerationRate:CYScrollViewDecelerationRateNormal];
429 [scroller_ setDelaysContentTouches:NO];
431 [scroller_ setCanCancelContentTouches:YES];
433 [scroller_ setAlwaysBounceVertical:NO];
434 } else if ([webview_ respondsToSelector:@selector(_scroller)]) {
435 UIScroller *scroller([webview_ _scroller]);
436 scroller_ = (UIScrollView *) scroller;
438 [scroller setDirectionalScrolling:YES];
439 [scroller setScrollDecelerationFactor:CYScrollViewDecelerationRateNormal]; /* 0.989324 */
440 [scroller setScrollHysteresis:0]; /* 8 */
442 [scroller setThumbDetectionEnabled:NO];
445 [webview_ setOpaque:NO];
446 [webview_ setBackgroundColor:[UIColor clearColor]];
448 [scroller_ setFixedBackgroundPattern:YES];
449 [scroller_ setBackgroundColor:[UIColor clearColor]];
450 [scroller_ setClipsSubviews:NO];
452 [scroller_ setBounces:YES];
453 [scroller_ setShowBackgroundShadow:NO]; /* YES */
455 [self setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
456 [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
458 NSDictionary *configuration([$CydgetController currentConfiguration]);
459 cycript_ = [configuration objectForKey:@"CycriptURLs"];
461 [scroller_ setScrollingEnabled:[[configuration objectForKey:@"Scrollable"] boolValue]];
467 - (void) webView:(WebView *)webview didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
469 if (NSString *href = [[[[frame dataSource] request] URL] absoluteString])
470 if (RegEx([cycript_ UTF8String])(href))
471 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
472 if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
473 WebFrame *frame([webview mainFrame]);
474 JSGlobalContextRef context([frame globalContext]);
476 CYSetupContext(context);
477 } @catch (NSException *e) {
478 NSLog(@"*** CydgetSetupContext => %@", e);
485 @interface WebCycriptLockScreenController : SBAwayViewPluginController {
486 NSDictionary *configuration_;
487 WebCydgetLockScreenView *background_;
517 union ScriptSourceCode {
519 JSC::SourceCode source_;
523 JSC::SourceCode source_;
527 // String Helpers {{{
528 static const UChar *(*_ZNK7WebCore6String10charactersEv)(const WebCore::String *);
529 static const UChar *(*_ZN7WebCore6String29charactersWithNullTerminationEv)(const WebCore::String *);
530 static unsigned (*_ZNK7WebCore6String6lengthEv)(const WebCore::String *);
532 static bool StringGet(const WebCore::String &string, const UChar *&data, size_t &length) {
535 if (_ZNK7WebCore6String10charactersEv != NULL) {
536 data = (*_ZNK7WebCore6String10charactersEv)(&string);
538 } else if (_ZN7WebCore6String29charactersWithNullTerminationEv != NULL) {
539 data = (*_ZN7WebCore6String29charactersWithNullTerminationEv)(&string);
546 if (_ZNK7WebCore6String6lengthEv != NULL)
547 length = (*_ZNK7WebCore6String6lengthEv)(&string);
549 for (length = 0; data[length] != 0; ++length);
555 static bool StringEquals(const WebCore::String &string, const char *value) {
558 if (!StringGet(string, data, size))
561 size_t length(strlen(value));
565 for (size_t index(0); index != length; ++index)
566 if (data[index] != value[index])
573 static bool cycript_;
575 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
576 if (!StringEquals(mime, "text/cycript")) {
578 return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
581 static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
589 // Script Compiler {{{
590 static void Log(const WebCore::String &string) {
594 if (!StringGet(string, data, length))
597 UChar terminated[length + 1];
598 terminated[length] = 0;
599 memcpy(terminated, data, length * 2);
600 NSLog(@"wtf %p:%zu:%S:", &string, length, terminated);
604 static bool Cycriptify(const uint16_t *&data, size_t &size) {
607 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
608 if (void (*CydgetMemoryParse)(const uint16_t **, size_t *) = reinterpret_cast<void (*)(const uint16_t **, size_t *)>(dlsym(handle, "CydgetMemoryParse"))) @try {
609 CydgetMemoryParse(&data, &size);
611 } @catch (NSException *e) {
612 NSLog(@"*** CydgetMemoryParse => %@", e);
617 static void (*_ZN7WebCore6String6appendEPKtj)(WebCore::String *, const UChar *, unsigned);
618 static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
620 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
627 if (!StringGet(source, data, length))
631 if (!Cycriptify(data, size))
634 WebCore::String &script(const_cast<WebCore::String &>(source));
635 _ZN7WebCore6String8truncateEj(&script, 0);
636 _ZN7WebCore6String6appendEPKtj(&script, data, size);
647 static WebCore::String *string;
650 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, void *_this, const WebCore::String &string, State state, const WebCore::String &url, int line) {
652 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line);
656 MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
658 JSC::SourceCode *source(_this[iOS32 ? 6 : 0]);
659 const uint16_t *data(source->data());
660 size_t size(source->length());
662 if (Cycriptify(data, size)) {
663 source->~SourceCode();
664 // XXX: I actually don't have the original URL here: pants
665 new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
670 return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
674 MSHook(const WebCore::String &, _ZNK7WebCore4Node11textContentEb, void *_this, bool convert) {
675 const WebCore::String &code(__ZNK7WebCore4Node11textContentEb(_this, convert));
676 string = const_cast<WebCore::String *>(&code);
683 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) {
685 return __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line);
689 MSHook(const WebCore::String &, _ZN7WebCore12CachedScript6scriptEv, void *_this) {
690 const WebCore::String &script(__ZN7WebCore12CachedScript6scriptEv(_this));
691 string = const_cast<WebCore::String *>(&script);
697 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, void *_this, JSC::ScriptSourceCode &script, State state) {
698 if (string != NULL) {
699 JSC::SourceCode *source(iOS4 ? &script.New.source_ : &script.Old.source_);
700 Cycriptify(*string, &source->end_);
704 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE(_this, script, state);
708 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
710 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE(_this, source, url, position);
714 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
716 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE(_this, position, legacy);
719 void (*$_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE)(void *_this, int legacy);
722 MSHook(void, _ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, void *_this, JSC::ScriptSourceCode &script) {
723 if (string != NULL) {
724 JSC::SourceCode *source(&script.New.source_);
725 $_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE(_this, 0);
726 Cycriptify(*string, &source->end_);
730 return __ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE(_this, script);
734 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
736 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE(_this, source, url, position);
740 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
742 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE(_this, position, legacy);
745 /* Cydget:// Protocol {{{ */
746 @interface CydgetURLProtocol : NSURLProtocol {
751 @implementation CydgetURLProtocol
753 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
754 NSURL *url([request URL]);
757 NSString *scheme([[url scheme] lowercaseString]);
758 if (scheme == nil || ![scheme isEqualToString:@"cydget"])
763 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
767 - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
768 id<NSURLProtocolClient> client([self client]);
770 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
772 NSData *data(UIImagePNGRepresentation(icon));
774 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
775 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
776 [client URLProtocol:self didLoadData:data];
777 [client URLProtocolDidFinishLoading:self];
781 - (void) startLoading {
782 id<NSURLProtocolClient> client([self client]);
783 NSURLRequest *request([self request]);
785 NSURL *url([request URL]);
786 NSString *href([url absoluteString]);
788 NSString *path([href substringFromIndex:9]);
789 NSRange slash([path rangeOfString:@"/"]);
792 if (slash.location == NSNotFound) {
796 command = [path substringToIndex:slash.location];
797 path = [path substringFromIndex:(slash.location + 1)];
800 if ([command isEqualToString:@"_UIImageWithName"]) {
803 path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
804 UIImage *icon(_UIImageWithName(path));
805 [self _returnPNGWithImage:icon forRequest:request];
807 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
811 - (void) stopLoading {
816 /* Cydget-CGI:// Protocol {{{ */
817 @interface CydgetCGIURLProtocol : NSURLProtocol {
819 CFHTTPMessageRef http_;
820 NSFileHandle *handle_;
825 @implementation CydgetCGIURLProtocol
827 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
828 NSURL *url([request URL]);
831 NSString *scheme([[url scheme] lowercaseString]);
832 if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
837 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
841 - (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)response client:(id<NSURLProtocolClient>)client {
842 if ((self = [super initWithRequest:request cachedResponse:response client:client]) != nil) {
847 - (void) startLoading {
848 id<NSURLProtocolClient> client([self client]);
849 NSURLRequest *request([self request]);
850 NSURL *url([request URL]);
852 NSString *path([url path]);
854 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
858 NSFileManager *manager([NSFileManager defaultManager]);
859 if (![manager fileExistsAtPath:path]) {
860 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
865 _assert(pipe(fds) != -1);
870 _assert(close(fds[0]) != -1);
871 _assert(close(fds[1]) != -1);
872 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
877 const char *script([path UTF8String]);
879 setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
880 setenv("SCRIPT_FILENAME", script, true);
881 NSString *query([url query]);
883 setenv("QUERY_STRING", [query UTF8String], true);
885 _assert(dup2(fds[1], 1) != -1);
886 _assert(close(fds[0]) != -1);
887 _assert(close(fds[1]) != -1);
889 execl(script, script, NULL);
894 _assert(close(fds[1]) != -1);
896 _assert(http_ == NULL);
897 http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
898 CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
900 _assert(handle_ == nil);
901 handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
903 [[NSNotificationCenter defaultCenter]
905 selector:@selector(onRead:)
906 name:@"NSFileHandleReadCompletionNotification"
910 [handle_ readInBackgroundAndNotify];
913 - (void) onRead:(NSNotification *)notification {
914 NSFileHandle *handle([notification object]);
916 NSData *data([[notification userInfo] objectForKey:NSFileHandleNotificationDataItem]);
918 if (size_t length = [data length]) {
919 CFHTTPMessageAppendBytes(http_, reinterpret_cast<const UInt8 *>([data bytes]), length);
920 [handle readInBackgroundAndNotify];
922 id<NSURLProtocolClient> client([self client]);
924 CFStringRef mime(CFHTTPMessageCopyHeaderFieldValue(http_, CFSTR("Content-type")));
926 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:nil]];
928 NSURLRequest *request([self request]);
930 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:(NSString *)mime expectedContentLength:-1 textEncodingName:nil] autorelease]);
933 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
935 CFDataRef body(CFHTTPMessageCopyBody(http_));
936 [client URLProtocol:self didLoadData:(NSData *)body];
939 [client URLProtocolDidFinishLoading:self];
947 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
949 - (void) stopLoading_ {
950 [[NSNotificationCenter defaultCenter] removeObserver:self];
952 if (handle_ != nil) {
960 _syscall(waitpid(pid_, &status, 0));
965 - (void) stopLoading {
967 performSelectorOnMainThread:@selector(stopLoading_)
976 template <typename Type_>
977 static void dlset(Type_ &function, const char *name) {
978 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
981 template <typename Type_>
982 static void msset_(Type_ &function, const char *name, MSImageRef handle) {
983 function = reinterpret_cast<Type_>(MSFindSymbol(handle, name));
986 #define msset(function, handle) \
987 msset_(function, "_" #function, handle)
989 @implementation WebCycriptLockScreenController
991 static void $UIWebViewWebViewDelegate$webView$addMessageToConsole$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, NSDictionary *message) {
992 UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
993 if ([uiWebView respondsToSelector:@selector(webView:addMessageToConsole:)])
994 [uiWebView webView:view addMessageToConsole:message];
997 static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIWebViewWebViewDelegate *self, SEL sel, WebView *view, WebScriptObject *window, WebFrame *frame) {
998 UIWebView *uiWebView(MSHookIvar<UIWebView *>(self, "uiWebView"));
999 if ([uiWebView respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
1000 [uiWebView webView:view didClearWindowObject:window forFrame:frame];
1003 + (void) initialize {
1004 if (Class $UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate")) {
1005 class_addMethod($UIWebViewWebViewDelegate, @selector(webView:addMessageToConsole:), (IMP) &$UIWebViewWebViewDelegate$webView$addMessageToConsole$, "v16@0:4@8@12");
1006 class_addMethod($UIWebViewWebViewDelegate, @selector(webView:didClearWindowObject:forFrame:), (IMP) &$UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$, "v20@0:4@8@12@16");
1009 if (CGFloat *_UIScrollViewDecelerationRateNormal = reinterpret_cast<CGFloat *>(dlsym(RTLD_DEFAULT, "UIScrollViewDecelerationRateNormal")))
1010 CYScrollViewDecelerationRateNormal = *_UIScrollViewDecelerationRateNormal;
1011 else // XXX: this actually might be fast on some older systems: we should look into this
1012 CYScrollViewDecelerationRateNormal = 0.998;
1014 iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
1015 iOS32 = !iOS4 && kCFCoreFoundationVersionNumber >= 478.61;
1018 size_t size(sizeof(maxproc));
1019 if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
1020 NSLog(@"sysctlbyname(\"kern.maxproc\", ?)");
1021 else if (maxproc < 72) {
1023 if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1)
1024 NSLog(@"sysctlbyname(\"kern.maxproc\", #)");
1027 [NSURLProtocol registerClass:[CydgetURLProtocol class]];
1028 [WebView registerURLSchemeAsLocal:@"cydget"];
1030 [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
1031 [WebView registerURLSchemeAsLocal:@"cydget-cgi"];
1033 MSImageRef JavaScriptCore(MSGetImageByName("/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore"));
1034 MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
1037 void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
1038 dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
1039 if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
1040 MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
1043 bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &) = NULL;
1044 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
1045 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE", WebCore);
1046 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
1047 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKN3WTF6StringE", WebCore);
1048 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL)
1049 MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
1051 void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int) = NULL;
1052 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi == NULL)
1053 MSHookSymbol(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, "__ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi", WebCore);
1054 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL)
1055 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
1058 const WebCore::String &(*_ZNK7WebCore4Node11textContentEb)(void *, bool) = NULL;
1059 if (_ZNK7WebCore4Node11textContentEb == NULL)
1060 MSHookSymbol(_ZNK7WebCore4Node11textContentEb, "__ZNK7WebCore4Node11textContentEb", WebCore);
1061 if (_ZNK7WebCore4Node11textContentEb != NULL)
1062 MSHookFunction(_ZNK7WebCore4Node11textContentEb, MSHake(_ZNK7WebCore4Node11textContentEb));
1065 const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *) = NULL;
1066 if (_ZN7WebCore12CachedScript6scriptEv == NULL)
1067 MSHookSymbol(_ZN7WebCore12CachedScript6scriptEv, "__ZN7WebCore12CachedScript6scriptEv", WebCore);
1068 if (_ZN7WebCore12CachedScript6scriptEv != NULL)
1069 MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
1071 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i)(void *, const WebCore::String &, State, const WebCore::String &, int) = NULL;
1072 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i == NULL)
1073 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i", WebCore);
1074 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL)
1075 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i));
1077 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, JSC::ScriptSourceCode &, State) = NULL;
1078 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE == NULL)
1079 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE", WebCore);
1080 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
1081 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
1083 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
1084 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, WebCore);
1085 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE != NULL)
1086 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE));
1088 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
1089 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, WebCore);
1090 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE != NULL)
1091 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE));
1093 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE)(void *, void *, int);
1094 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, WebCore);
1095 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE != NULL)
1096 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE));
1098 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE)(void *, void *, int);
1099 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, WebCore);
1100 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE != NULL)
1101 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE));
1103 MSHookSymbol($_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE, "__ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE", WebCore);
1105 void (*_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE)(void *, JSC::ScriptSourceCode &);
1106 msset(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, WebCore);
1107 if (_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE != NULL)
1108 MSHookFunction(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, MSHake(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE));
1110 if (_ZN7WebCore6String6appendEPKtj == NULL)
1111 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN7WebCore6String6appendEPKtj", WebCore);
1112 if (_ZN7WebCore6String6appendEPKtj == NULL)
1113 msset(_ZN7WebCore6String6appendEPKtj, JavaScriptCore);
1114 if (_ZN7WebCore6String6appendEPKtj == NULL)
1115 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN3WTF6String6appendEPKtj", JavaScriptCore);
1117 if (_ZN7WebCore6String8truncateEj == NULL)
1118 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN7WebCore6String8truncateEj", WebCore);
1119 if (_ZN7WebCore6String8truncateEj == NULL)
1120 msset(_ZN7WebCore6String8truncateEj, JavaScriptCore);
1121 if (_ZN7WebCore6String8truncateEj == NULL)
1122 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN3WTF6String8truncateEj", JavaScriptCore);
1124 msset(_ZNK7WebCore6String10charactersEv, WebCore);
1126 msset(_ZN7WebCore6String29charactersWithNullTerminationEv, JavaScriptCore);
1127 if (_ZN7WebCore6String29charactersWithNullTerminationEv == NULL)
1128 MSHookSymbol(_ZN7WebCore6String29charactersWithNullTerminationEv, "__ZN3WTF6String29charactersWithNullTerminationEv", JavaScriptCore);
1130 msset(_ZNK7WebCore6String6lengthEv, WebCore);
1133 + (id) rootViewController {
1134 return [[[self alloc] init] autorelease];
1138 [configuration_ release];
1139 [background_ release];
1144 if ((self = [super init]) != nil) {
1145 configuration_ = [[$CydgetController currentConfiguration] retain];
1150 NSURL *base([NSURL fileURLWithPath:[$CydgetController currentPath]]);
1152 if (NSString *background = [configuration_ objectForKey:@"Background"])
1153 background_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:background relativeToURL:base]];
1155 if (NSString *homepage = [configuration_ objectForKey:@"Homepage"])
1156 [self setView:[[[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:homepage relativeToURL:base]] autorelease]];
1157 else if (kCFCoreFoundationVersionNumber < 800 && background_ != nil) {
1158 [self setView:[background_ autorelease]];
1163 - (void) purgeView {
1164 [background_ removeFromSuperview];
1165 [background_ release];
1170 - (UIView *) backgroundView {
1174 - (BOOL) showAwayItems {
1178 - (BOOL) showDateView {
1179 return [configuration_ objectForKey:@"Homepage"] == nil;
1182 /*- (BOOL) showHeaderView {
1186 - (NSUInteger) presentationStyle {
1190 - (NSUInteger) overlayStyle {
1191 if ([configuration_ objectForKey:@"Background"] == nil)
1196 - (BOOL) viewWantsFullscreenLayout {
1197 return kCFCoreFoundationVersionNumber >= 800;
1200 /*- (BOOL) viewWantsOverlayLayout {
1201 return kCFCoreFoundationVersionNumber >= 800;
1204 - (BOOL) shouldDisableOnUnlock {
1208 - (BOOL) canBeAlwaysFullscreen {
1212 /*- (BOOL) wantsSwipeGestureRecognizer {
1216 - (BOOL) handleGesture:(int)arg1 fingerCount:(NSUInteger)fingers {
1221 - (BOOL) handleMenuButtonDoubleTap {
1222 if (kCFCoreFoundationVersionNumber >= 800) {
1223 SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]);
1224 [controller _setMediaControlsVisible:![controller isShowingMediaControls]];
1227 return [super handleMenuButtonDoubleTap];
1232 MSClassHook(WebView)
1233 MSMetaClassHook(WebView)
1235 MSClassMessageHook0(void, WebView, enableWebThread) {
1236 if (kCFCoreFoundationVersionNumber >= 478.61)
1239 NSLog(@"-[WebView enableWebThread]");