From 9d450f87b82708c99f2e058bd6f9557218ae75a2 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 5 Apr 2010 09:32:02 +0000 Subject: [PATCH] Use cydget-cgi instead of cydget-php, and fix the threading issues. --- LockScreen.mm | 35 ++++++++++++++++++++++++----------- control | 2 +- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/LockScreen.mm b/LockScreen.mm index ccba730..5e26660 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -992,8 +992,8 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6 @end /* }}} */ -/* Cydget-PHP:// Protocol {{{ */ -@interface CydgetPHPURLProtocol : NSURLProtocol { +/* Cydget-CGI:// Protocol {{{ */ +@interface CydgetCGIURLProtocol : NSURLProtocol { pid_t pid_; CFHTTPMessageRef http_; NSFileHandle *handle_; @@ -1001,14 +1001,14 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6 @end -@implementation CydgetPHPURLProtocol +@implementation CydgetCGIURLProtocol + (BOOL) canInitWithRequest:(NSURLRequest *)request { NSURL *url([request URL]); if (url == nil) return NO; NSString *scheme([[url scheme] lowercaseString]); - if (scheme == nil || ![scheme isEqualToString:@"cydget-php"]) + if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"]) return NO; return YES; } @@ -1029,7 +1029,7 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6 NSURL *url([request URL]); NSString *path([url path]); - if (path == nil || ![path hasSuffix:@".php"]) { + if (path == nil) { [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]]; return; } @@ -1053,8 +1053,10 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6 } if (pid_ == 0) { + const char *script([path UTF8String]); + setenv("GATEWAY_INTERFACE", "CGI/1.1", true); - setenv("SCRIPT_FILENAME", [path UTF8String], true); + setenv("SCRIPT_FILENAME", script, true); NSString *query([url query]); if (query != nil) setenv("QUERY_STRING", [query UTF8String], true); @@ -1063,7 +1065,7 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6 _assert(close(fds[0]) != -1); _assert(close(fds[1]) != -1); - execl("/usr/bin/php-cgi", "php-cgi", NULL); + execl(script, script, NULL); exit(1); _assert(false); } @@ -1123,10 +1125,13 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]]; -- (void) stopLoading { +- (void) stopLoading_ { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [handle_ release]; - handle_ = nil; + + if (handle_ != nil) { + [handle_ release]; + handle_ = nil; + } if (pid_ != -1) { kill(pid_, SIGTERM); @@ -1136,6 +1141,14 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6 } } +- (void) stopLoading { + [self + performSelectorOnMainThread:@selector(stopLoading_) + withObject:nil + waitUntilDone:NO + ]; +} + @end /* }}} */ @@ -1169,7 +1182,7 @@ static void dlset(Type_ &function, const char *name) { apr_initialize(); [NSURLProtocol registerClass:[CydgetURLProtocol class]]; - [NSURLProtocol registerClass:[CydgetPHPURLProtocol class]]; + [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]]; void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *); dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE"); diff --git a/control b/control index c7502ac..ce1faae 100644 --- a/control +++ b/control @@ -3,7 +3,7 @@ Priority: optional Section: Development Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.3107-1 +Version: 0.9.3141-1 Description: framework for managing lock screen plugins Name: Cydget Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), preferenceloader, apr-lib, pcre, cycript (>= 0.9.292-1) -- 2.45.2