#include "SourceCode.h"
#include <apr-1/apr_pools.h>
+#include <pcre.h>
@interface WebView (UICaboodle)
- (void) setScriptDebugDelegate:(id)delegate;
@end
+/* Perl-Compatible RegEx {{{ */
+class Pcre {
+ private:
+ pcre *code_;
+ pcre_extra *study_;
+ int capture_;
+ int *matches_;
+ const char *data_;
+
+ public:
+ Pcre(const char *regex, int options = 0) :
+ study_(NULL)
+ {
+ const char *error;
+ int offset;
+ code_ = pcre_compile(regex, options, &error, &offset, NULL);
+
+ if (code_ == NULL)
+ @throw [NSException exceptionWithName:NSInvalidArgumentException reason:[NSString stringWithFormat:@"*** Pcre(,): [%u] %s", offset, error] userInfo:nil];
+
+ pcre_fullinfo(code_, study_, PCRE_INFO_CAPTURECOUNT, &capture_);
+ matches_ = new int[(capture_ + 1) * 3];
+ }
+
+ ~Pcre() {
+ pcre_free(code_);
+ delete matches_;
+ }
+
+ NSString *operator [](size_t match) {
+ return [[[NSString alloc] initWithBytes:(data_ + matches_[match * 2]) length:(matches_[match * 2 + 1] - matches_[match * 2]) encoding:NSUTF8StringEncoding] autorelease];
+ }
+
+ bool operator ()(NSString *data) {
+ // XXX: length is for characters, not for bytes
+ return operator ()([data UTF8String], [data length]);
+ }
+
+ bool operator ()(const char *data, size_t size) {
+ data_ = data;
+ return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
+ }
+};
+/* }}} */
/* WebCycript Delegate {{{ */
@interface WebCycriptDelegate : NSObject {
_transient volatile id delegate_;
UIScroller *scroller_;
UIWebDocumentView *document_;
- bool cycript_;
+ NSString *cycript_;
bool scrollable_;
float width_;
NSDictionary *configuration([$CydgetController currentConfiguration]);
- cycript_ = [[configuration objectForKey:@"Cycript"] boolValue];
+ cycript_ = [configuration objectForKey:@"Cycript"];
scrollable_ = [[configuration objectForKey:@"Scrollable"] boolValue];
[scroller_ setScrollingEnabled:scrollable_];
}
- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
- if (cycript_)
- if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
- if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
- WebView *webview([document_ webView]);
- WebFrame *frame([webview mainFrame]);
- JSGlobalContextRef context([frame globalContext]);
- CYSetupContext(context);
- }
+ if (cycript_ != nil)
+ if (NSString *href = [[[[frame dataSource] request] URL] absoluteString])
+ if (Pcre([cycript_ UTF8String], 0 /*XXX:PCRE_UTF8*/)(href))
+ if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
+ if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
+ WebView *webview([document_ webView]);
+ WebFrame *frame([webview mainFrame]);
+ JSGlobalContextRef context([frame globalContext]);
+ CYSetupContext(context);
+ }
}
- (bool) isLoading {
Section: Development
Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
Architecture: iphoneos-arm
-Version: 0.9.3083-1
+Version: 0.9.3084-1
Description: framework for managing lock screen plugins
Name: Cydget
-Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), preferenceloader, apr-lib
+Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), preferenceloader, apr-lib, pcre
Replaces: cydialer (<< 0.9.17)
Author: Jay Freeman (saurik) <saurik@saurik.com>
Depiction: http://cydia.saurik.com/info/cydget/
ldid -S $@
WebCycriptLockScreen: LockScreen.mm makefile $(base)/../mobilesubstrate/substrate.h
- $(target)g++ -F. -bundle -mthumb -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -lobjc -I$(base)/../mobilesubstrate $(link) $(flags) -framework CoreGraphics -framework QuartzCore -framework SpringBoardUI -framework WebCore -framework GraphicsServices -framework TelephonyUI -I$(jscore) -iquote$(webcore)/{bindings/js,dom,loader,platform{,/animation,/cf,/network{,/cf},/text},/rendering/style} -iquote$(jscore)/{bytecode,debugger,interpreter,jit,parser,runtime} -lapr-1 -weak_reference_mismatches weak -framework JavaScriptCore
+ $(target)g++ -F. -bundle -mthumb -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -lobjc -I$(base)/../mobilesubstrate $(link) $(flags) -framework CoreGraphics -framework QuartzCore -framework SpringBoardUI -framework WebCore -framework GraphicsServices -framework TelephonyUI -I$(jscore) -iquote$(webcore)/{bindings/js,dom,loader,platform{,/animation,/cf,/network{,/cf},/text},/rendering/style} -iquote$(jscore)/{bytecode,debugger,interpreter,jit,parser,runtime} -lapr-1 -weak_reference_mismatches weak -framework JavaScriptCore -lpcre
ldid -S $@
extra: