]> git.saurik.com Git - cydget.git/commitdiff
Use cydget-cgi instead of cydget-php, and fix the threading issues.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 5 Apr 2010 09:32:02 +0000 (09:32 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 5 Apr 2010 09:32:02 +0000 (09:32 +0000)
LockScreen.mm
control

index ccba730f3f506b7b331c793a58b19cf5bae12276..5e26660212607f7def5ef01b920c05a952e2aea7 100644 (file)
@@ -992,8 +992,8 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
 
 @end
 /* }}} */
 
 @end
 /* }}} */
-/* Cydget-PHP:// Protocol {{{ */
-@interface CydgetPHPURLProtocol : NSURLProtocol {
+/* Cydget-CGI:// Protocol {{{ */
+@interface CydgetCGIURLProtocol : NSURLProtocol {
     pid_t pid_;
     CFHTTPMessageRef http_;
     NSFileHandle *handle_;
     pid_t pid_;
     CFHTTPMessageRef http_;
     NSFileHandle *handle_;
@@ -1001,14 +1001,14 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
 
 @end
 
 
 @end
 
-@implementation CydgetPHPURLProtocol
+@implementation CydgetCGIURLProtocol
 
 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
     NSURL *url([request URL]);
     if (url == nil)
         return NO;
     NSString *scheme([[url scheme] lowercaseString]);
 
 + (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;
 }
         return NO;
     return YES;
 }
@@ -1029,7 +1029,7 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
     NSURL *url([request URL]);
 
     NSString *path([url path]);
     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;
     }
         [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
         return;
     }
@@ -1053,8 +1053,10 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
     }
 
     if (pid_ == 0) {
     }
 
     if (pid_ == 0) {
+        const char *script([path UTF8String]);
+
         setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
         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);
         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);
 
         _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);
     }
         exit(1);
         _assert(false);
     }
@@ -1123,10 +1125,13 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
 
     //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
 
 
     //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
 
-- (void) stopLoading {
+- (void) stopLoading_ {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [[NSNotificationCenter defaultCenter] removeObserver:self];
-    [handle_ release];
-    handle_ = nil;
+
+    if (handle_ != nil) {
+        [handle_ release];
+        handle_ = nil;
+    }
 
     if (pid_ != -1) {
         kill(pid_, SIGTERM);
 
     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
 /* }}} */
 
 @end
 /* }}} */
 
@@ -1169,7 +1182,7 @@ static void dlset(Type_ &function, const char *name) {
     apr_initialize();
 
     [NSURLProtocol registerClass:[CydgetURLProtocol class]];
     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");
 
     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 c7502acf6a5e3ed550b202cc3acedabb56055ccf..ce1faae845e65b5bb4ac864b911c1b49d5c93e1c 100644 (file)
--- a/control
+++ b/control
@@ -3,7 +3,7 @@ Priority: optional
 Section: Development
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
 Section: Development
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 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)
 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)