From 5f249c0b313a491aae6a65938eeb46f84befac2d Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 24 Jan 2014 14:24:41 -0800 Subject: [PATCH] Implement Cydget-specific media/bulletins @media. --- LockScreen.mm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/LockScreen.mm b/LockScreen.mm index 750ff7a..1572e5e 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -131,10 +131,15 @@ typedef uint16_t UChar; - (BOOL) mediaControlsHidden; @end +@interface SBLockScreenNotificationListController : NSObject +- (BOOL) hasAnyContent; +@end + @interface SBLockScreenViewController : UIViewController - (SBLockScreenView *) lockScreenView; - (BOOL) isShowingMediaControls; - (void) _setMediaControlsVisible:(BOOL)visible; +- (SBLockScreenNotificationListController *) _notificationController; @end @interface SBLockScreenManager : NSObject @@ -508,9 +513,13 @@ namespace JSC { namespace WebCore { class KURL; - class String; } +namespace WebCore { +struct String { + void *impl_; +}; } + namespace JSC { struct SourceCode { void *provider_; @@ -979,6 +988,41 @@ MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0 @end /* }}} */ +namespace WebCore { + class MediaQueryEvaluator; + class CSSParserValueList; +} + +namespace WebCore { +struct MediaQueryExp { + String feature_; + void *value_; + bool valid_; + String cache_; +}; } + +MSHook(bool, _ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, WebCore::MediaQueryEvaluator *_this, WebCore::String &query) { + Log(query); if (false) { + } else if (kCFCoreFoundationVersionNumber >= 800 && StringEquals(query, "cydget-media-controls")) { + SBLockScreenView *view([[[$SBLockScreenManager sharedInstance] lockScreenViewController] lockScreenView]); + return view != nil && ![view mediaControlsHidden]; + //return [[[$SBLockScreenManager sharedInstance] lockScreenViewController] isShowingMediaControls]; + } else if (kCFCoreFoundationVersionNumber >= 800 && StringEquals(query, "cydget-notification-list")) { + SBLockScreenNotificationListController *controller([[[$SBLockScreenManager sharedInstance] lockScreenViewController] _notificationController]); + return controller != nil && [controller hasAnyContent]; + } else + return __ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE(_this, query); +} + +MSHook(void, _ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, WebCore::MediaQueryExp *_this, WebCore::String &query, WebCore::CSSParserValueList *values) { + Log(query); + __ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE(_this, query, values); + if (!_this->valid_) if ( + StringEquals(query, "cydget-media-controls") || + StringEquals(query, "cydget-notification-list") || + false) _this->valid_ = true; +} + template static void dlset(Type_ &function, const char *name) { function = reinterpret_cast(dlsym(RTLD_DEFAULT, name)); @@ -1134,6 +1178,16 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW MSHookSymbol(_ZN7WebCore6String29charactersWithNullTerminationEv, "__ZN3WTF6String29charactersWithNullTerminationEv", JavaScriptCore); msset(_ZNK7WebCore6String6lengthEv, WebCore); + + bool (*_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE)(WebCore::MediaQueryEvaluator *, WebCore::String &); + msset(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, WebCore); + if (_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE != NULL) + MSHookFunction(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, MSHake(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE)); + + void (*_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE)(WebCore::MediaQueryExp *, WebCore::String &, WebCore::CSSParserValueList *); + msset(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, WebCore); + if (_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE != NULL) + MSHookFunction(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, MSHake(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE)); } + (id) rootViewController { -- 2.45.2