diff options
-rw-r--r-- | Cydia.app/compose.png | bin | 0 -> 690 bytes | |||
-rw-r--r-- | Cydia.app/menes/chevron.png (renamed from Cydia.app/menes/listArrow.png) | bin | 289 -> 289 bytes | |||
-rw-r--r-- | Cydia.app/menes/menes.js | 236 | ||||
-rw-r--r-- | Cydia.app/menes/style.css | 102 | ||||
-rw-r--r-- | Cydia.app/package.html | 6 | ||||
-rw-r--r-- | Cydia.mm | 65 | ||||
-rw-r--r-- | exec.mm | 66 | ||||
-rwxr-xr-x | make.sh | 2 | ||||
-rw-r--r-- | makefile | 11 |
9 files changed, 292 insertions, 196 deletions
diff --git a/Cydia.app/compose.png b/Cydia.app/compose.png Binary files differnew file mode 100644 index 0000000..1141d5d --- /dev/null +++ b/Cydia.app/compose.png diff --git a/Cydia.app/menes/listArrow.png b/Cydia.app/menes/chevron.png Binary files differindex 6ff8205..6ff8205 100644 --- a/Cydia.app/menes/listArrow.png +++ b/Cydia.app/menes/chevron.png diff --git a/Cydia.app/menes/menes.js b/Cydia.app/menes/menes.js index f314227..8148d8d 100644 --- a/Cydia.app/menes/menes.js +++ b/Cydia.app/menes/menes.js @@ -1,10 +1,12 @@ -var _assert = function (expr) { +/* XXX: this message is ultra-lame */ +var _assert = function (expr, value) { if (!expr) { - var message = "_assert(" + expr + ")"; - alert(message); + var message = "_assert(" + value + ")"; + console.log(message); throw message; } } + // Compatibility {{{ if (typeof Array.prototype.push != "function") Array.prototype.push = function (value) { @@ -16,26 +18,29 @@ var $ = function (arg, doc) { if (this.magic_ != $.prototype.magic_) return new $(arg); + if (arg == null) + arg = []; + var type = $.type(arg); if (type == "function") $.ready(arg); else if (type == "string") { - if (doc == undefined) + if (typeof doc == 'undefined') doc = document; if (arg.charAt(0) == '#') { - var node = doc.getElementById(arg.substring(1)); - return $(node == null ? [] : [node]); - } else if (arg.charAt(0) == '.') { - var nodes = doc.getElementsByClassName(arg.substring(1)); - return $(nodes == null ? [] : nodes); - } else + /* XXX: this is somewhat incorrect-a-porter */ + var element = doc.getElementById(arg.substring(1)); + return $(element == null ? [] : [element]); + } else if (arg.charAt(0) == '.') + return $(doc.getElementsByClassName(arg.substring(1))); + else return $([doc]).descendants(arg); - } else { - _assert(doc == undefined); - this.set($.array(arg)); + } else if (typeof arg.length != 'undefined') { + _assert(typeof doc == 'undefined', "non-query with document to $"); + this.set(arg); return this; - } + } else _assert(false, "unknown argument to $: " + typeof arg); }; $.xml = function (value) { @@ -51,14 +56,13 @@ $.xml = function (value) { $.type = function (value) { var type = typeof value; - if ( - type == "function" && - value.toString != null && - value.toString().substring(0, 8) == "[object " - ) - return "object"; - else - return type; + if ((type == "function" || type == "object") && value.toString != null) { + var string = value.toString(); + if (string.substring(0, 8) == "[object ") + return string.substring(8, string.length - 1); + } + + return type; }; (function () { @@ -95,6 +99,7 @@ $.map = function (values, _function, arg0, arg1, arg2) { $.array = function (values) { if (values.constructor == Array) return values; + _assert(typeof values.length != 'undefined', "$.array on underlying non-array"); var array = []; for (var i = 0; i != values.length; ++i) array.push(values[i]); @@ -110,11 +115,30 @@ $.document = function (node) { } }; +$.reclass = function (_class) { + return new RegExp('(\\s|^)' + _class + '(\\s|$)'); +}; + $.prototype = { magic_: 2041085062, add: function (nodes) { - Array.prototype.push.apply(this, nodes); + Array.prototype.push.apply(this, $.array(nodes)); + }, + + at: function (name, value) { + if (typeof value == 'undefined') + return $.map(this, function (node) { + return node.getAttribute(name); + }); + else if (value == null) + $.each(this, function (node) { + node.removeAttribute(); + }); + else + $.each(this, function (node) { + node.setAttribute(name, value); + }); }, set: function (nodes) { @@ -122,14 +146,52 @@ $.prototype = { this.add(nodes); }, + /* XXX: verify arg3 overflow */ + each: function (_function, arg0, arg1, arg2) { + $.each(this, function (node) { + _function($([node]), arg0, arg1, arg2); + }); + }, + css: function (name, value) { $.each(this, function (node) { node.style[name] = value; }); }, + addClass: function (_class) { + $.each(this, function (node) { + if (!$([node]).hasClass(_class)[0]) + node.className += " " + _class; + }); + }, + + blur: function () { + $.each(this, function (node) { + node.blur(); + }); + }, + + focus: function () { + $.each(this, function (node) { + node.focus(); + }); + }, + + removeClass: function (_class) { + $.each(this, function (node) { + node.className = node.className.replace($.reclass(_class), ' '); + }); + }, + + hasClass: function (_class) { + return $.map(this, function (node) { + return node.className.match($.reclass(_class)); + }); + }, + append: function (html) { - $.each(this, $.type(html) == "string" ? function (node) { + $.each(this, function (node) { var doc = $.document(node); // XXX: implement wrapper system @@ -140,24 +202,15 @@ $.prototype = { var child = div.childNodes[0]; node.appendChild(child); } - } : function (node) { - $.each(html, function (value) { - node.appendChild(value); - }); }); }, - clone: function (deep) { - return $($.map(this, function (node) { - return node.cloneNode(deep); - })); - }, - descendants: function (expression) { var descendants = $([]); $.each(this, function (node) { - descendants.add(node.getElementsByTagName(expression)); + var nodes = node.getElementsByTagName(expression); + descendants.add(nodes); }); return descendants; @@ -167,31 +220,6 @@ $.prototype = { $.each(this, function (node) { node.parentNode.removeChild(node); }); - }, - - parent: function () { - return $($.map(this, function (node) { - return node.parentNode; - })); - }, - - xpath: function (expression) { - var value = $([]); - - $.each(this, function (node) { - var doc = $.document(node); - var result = doc.evaluate(expression, node, null, XPathResult.ANY_TYPE, null); - - if (result.resultType == XPathResult.UNORDERED_NODE_ITERATOR_TYPE) - for (;;) { - var next = result.iterateNext(); - if (next == null) - break; - value.add([next]); - } - }); - - return value; } }; @@ -201,7 +229,7 @@ $.scroll = function (x, y) { // XXX: document.all? $.all = function (doc) { - if (doc == undefined) + if (typeof doc == 'undefined') doc = document; return $(doc.getElementsByTagName("*")); }; @@ -209,7 +237,7 @@ $.all = function (doc) { $.inject = function (a, b) { if ($.type(a) == "string") { $.prototype[a] = function (value) { - if (value == undefined) + if (typeof value == 'undefined') return $.map(this, function (node) { return b.get(node); }); @@ -223,6 +251,15 @@ $.inject = function (a, b) { }; $.inject({ + _default: { + get: function (node) { + return node.style.defaultValue; + }, + set: function (node, value) { + node.style.defaultValue = value; + } + }, + display: { get: function (node) { return node.style.display; @@ -250,12 +287,18 @@ $.inject({ } }, - id: { + name: { get: function (node) { - return node.id; + return node.name; }, set: function (node, value) { - node.id = value; + node.name = value; + } + }, + + parent: { + get: function (node) { + return node.parentNode; } }, @@ -268,16 +311,73 @@ $.inject({ } }, + type: { + get: function (node) { + return node.localName; + } + }, + value: { get: function (node) { return node.value; }, set: function (node, value) { - node.value = value; + // XXX: do I really need this? + if (true || node.localName != "select") + node.value = value; + else { + var options = node.options; + for (var i = 0, e = options.length; i != e; ++i) + if (options[i].value == value) { + if (node.selectedIndex != i) + node.selectedIndex = i; + break; + } + } + } + }, + + width: { + get: function (node) { + return node.offsetWidth; } } }); +// Query String Parsing {{{ +$.query = function () { + var args = {}; + + var search = location.search; + if (search != null) { + _assert(search[0] == "?", "query string without ?"); + + var values = search.substring(1).split("&"); + for (var index in values) { + var value = values[index] + var equal = value.indexOf("="); + var name; + + if (equal == -1) { + name = value; + value = null; + } else { + name = value.substring(0, equal); + value = value.substring(equal + 1); + value = decodeURIComponent(value); + } + + name = decodeURIComponent(name); + if (typeof args[name] == "undefined") + args[name] = []; + if (value != null) + args[name].push(value); + } + } + + return args; +}; +// }}} // Event Registration {{{ // XXX: unable to remove registration $.prototype.event = function (event, _function) { @@ -297,8 +397,8 @@ $.each([ "click", "load", "submit" ], function (event) { $.prototype[event] = function (_function) { - if (_function == undefined) - _assert(false); + if (typeof _function == 'undefined') + _assert(false, "undefined function to $.[event]"); else this.event(event, _function); }; diff --git a/Cydia.app/menes/style.css b/Cydia.app/menes/style.css index a0bb3d2..223c975 100644 --- a/Cydia.app/menes/style.css +++ b/Cydia.app/menes/style.css @@ -65,6 +65,13 @@ vertical-align: baseline; } +sup { + font-size: smaller; + margin-top: -6px; + position: relative; + top: -6px; +} + select { border: 1px solid #999999; } @@ -112,6 +119,10 @@ pre { letter-spacing: -2px; } +.default { + color: #aaaabb; +} + /* #toolbar {{{ */ dialog > toolbar { background: url(toolbar.png) #6d84a2 repeat-x; @@ -181,6 +192,22 @@ dialog > panel > fieldset { margin: 9px; } +dialog > panel > input[type="submit"] { + /*-webkit-border-image: url(whiteButton.png) 0 12 0 12; + -webkit-border-radius: 0; + border-width: 0px 12px;*/ + border: none; + color: #000000; + display: block; + font-size: 20px; + font-weight: bold; + margin: 9px; + height: 44px; + padding: 10px; + text-align: center; + width: 302px; +} + dialog > panel > label { display: block; margin: 13px 0 -4px 27px; @@ -233,37 +260,39 @@ fieldset > div > ul:last-child { margin-bottom: 0; } -dialog > fieldset > a { - background: 295px 13px no-repeat url(listArrow.png); -} - -dialog > panel > fieldset > a { - background: 275px 13px no-repeat url(listArrow.png); -} - fieldset > a { color: inherit; display: block; } -dialog > fieldset > div > select { +fieldset > textarea, +fieldset > div > input, +fieldset > div > select { background: none; - margin: -13px -17px -13px 86px; - border-left: 0; - border-right: 0; - height: 44px; - width: 217px; + -webkit-box-shadow: none; + -webkit-appearance: none; } -dialog > panel > fieldset > div > select { - margin: -5px -10px -5px 86px; - -webkit-border-radius: 5px; - width: 190px; +fieldset > a, +fieldset > div > select { + background: no-repeat url(chevron.png); + background-position-y: 13px; } -fieldset > textarea, -fieldset > div > input { - background: none; +dialog > fieldset > a { + background-position-x: 295px; +} + +dialog > panel > fieldset > a { + background-position-x: 275px; +} + +dialog > fieldset > div > select { + background-position-x: 192px; +} + +dialog > panel > fieldset > div > select { + background-position-x: 172px; } fieldset > textarea, @@ -280,35 +309,30 @@ fieldset > div > select { font-size: 16px; } +fieldset > div > select, fieldset > div > input { border: none; - height: 45px; - margin: -13px -18px; - padding: 13px 10px 0 111px; -} - -fieldset > textarea { - padding: 10px; - width: 320px; + height: 44px; + margin: -13px -17px -13px 86px; } +dialog > panel > fieldset > div > select, dialog > panel > fieldset > div > input { - width: 302px; + width: 187px; } +dialog > fieldset > div > select, dialog > fieldset > div > input { - width: 320px; + width: 207px; } -fieldset > div > input[type="submit"] { - border-width: 0 12px; - color: #000000; - display: block; - font-size: 20px; - font-weight: bold; +fieldset > div > input { + padding: 13px 7px; +} + +fieldset > textarea { padding: 10px; - text-align: center; - -webkit-border-image: url(whiteButton.png) 0 12 0 12; + width: 320px; } fieldset > a > label, diff --git a/Cydia.app/package.html b/Cydia.app/package.html index 3b0d7ba..faba915 100644 --- a/Cydia.app/package.html +++ b/Cydia.app/package.html @@ -114,11 +114,11 @@ } #lower { - margin: 12px 5px; + margin: 10px 5px; } #name { - margin: 5px 5px; + margin: 7px 5px; font-weight: bold; } @@ -142,7 +142,7 @@ padding: 10px; } </style> -</head><body> +</head><body class="pinstripe"> <dialog><panel> <fieldset id="header"> @@ -61,11 +61,15 @@ #include <WebKit/WebFrame.h> #include <WebKit/WebPolicyDelegate.h> +#include <WebKit/WebPreferences.h> #include <WebKit/WebScriptObject.h> #import <WebKit/WebView.h> #import <WebKit/WebView-WebPrivate.h> +#include <WebCore/Page.h> +#include <WebCore/Settings.h> + #import <JavaScriptCore/JavaScriptCore.h> #include <sstream> @@ -109,6 +113,8 @@ extern "C" { #import "BrowserView.h" #import "ResetView.h" + +#import "substrate.h" /* }}} */ //#define _finline __attribute__((force_inline)) @@ -271,7 +277,7 @@ extern NSString * const kCAFilterNearest; #define lprintf(args...) fprintf(stderr, args) -#define ForRelease 0 +#define ForRelease 1 #define ForSaurik (1 && !ForRelease) #define RecycleWebViews 0 #define AlwaysReload (1 && !ForRelease) @@ -2863,7 +2869,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return @"Cancel"; } -- (NSString *) _rightButtonTitle { +- (id) _rightButtonTitle { return issues_ == nil ? @"Confirm" : nil; } @@ -3911,7 +3917,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } #endif -- (NSString *) _rightButtonTitle { +- (id) _rightButtonTitle { int count = [buttons_ count]; return count == 0 ? nil : count != 1 ? @"Modify" : [buttons_ objectAtIndex:0]; } @@ -4600,7 +4606,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return [[list_ table] isRowDeletionEnabled] ? @"Add" : nil; } -- (NSString *) rightButtonTitle { +- (id) rightButtonTitle { return [[list_ table] isRowDeletionEnabled] ? @"Done" : @"Edit"; } @@ -4671,7 +4677,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return @"Packages"; } -- (NSString *) rightButtonTitle { +- (id) rightButtonTitle { return Role_ != nil && [Role_ isEqualToString:@"Developer"] ? nil : expert_ ? @"Expert" : @"Simple"; } @@ -4758,7 +4764,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } #if !AlwaysReload -- (NSString *) _rightButtonTitle { +- (id) _rightButtonTitle { return nil; } #endif @@ -5004,6 +5010,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { + (NSString *) webScriptNameForSelector:(SEL)selector { if (selector == @selector(getPackageById:)) return @"getPackageById"; + else if (selector == @selector(setButtonImage:withStyle:toFunction:)) + return @"setButtonImage"; else if (selector == @selector(setButtonTitle:withStyle:toFunction:)) return @"setButtonTitle"; else if (selector == @selector(supports:)) @@ -5024,6 +5032,20 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return [[Database sharedInstance] packageWithName:id]; } +- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function { + if (button_ != nil) + [button_ autorelease]; + button_ = button == nil ? nil : [[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:button]]] retain]; + + if (style_ != nil) + [style_ autorelease]; + style_ = style == nil ? nil : [style retain]; + + if (function_ != nil) + [function_ autorelease]; + function_ = function == nil ? nil : [function retain]; +} + - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function { if (button_ != nil) [button_ autorelease]; @@ -5466,7 +5488,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { webview = [webview_ webView]; // XXX: this is terribly (too?) expensive - [webview_ setDrawsBackground:NO]; + //[webview_ setDrawsBackground:NO]; + [webview setPreferencesIdentifier:@"Cydia"]; [webview_ setTileSize:CGSizeMake(webrect.size.width, 500)]; @@ -5542,18 +5565,36 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { reloading_ = true; [self reloadURL]; } else { + WebView *webview([webview_ webView]); + WebFrame *frame([webview mainFrame]); + + id _private(MSHookIvar<id>(webview, "_private")); + WebCore::Page *page(_private == nil ? NULL : MSHookIvar<WebCore::Page *>(_private, "page")); + WebCore::Settings *settings(page == NULL ? NULL : page->settings()); + + bool no; + if (settings == NULL) + no = 0; + else { + no = settings->JavaScriptCanOpenWindowsAutomatically(); + settings->setJavaScriptCanOpenWindowsAutomatically(true); + } + [delegate_ clearFirstResponder]; JSObjectRef function([function_ JSObject]); - JSGlobalContextRef context([[[webview_ webView] mainFrame] globalContext]); + JSGlobalContextRef context([frame globalContext]); JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL); + + if (settings != NULL) + settings->setJavaScriptCanOpenWindowsAutomatically(no); } } -- (NSString *) _rightButtonTitle { +- (id) _rightButtonTitle { return button_ != nil ? button_ : @"Reload"; } -- (NSString *) rightButtonTitle { +- (id) rightButtonTitle { return [self _loading] ? @"" : [self _rightButtonTitle]; } @@ -6154,7 +6195,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return @"Sections"; } -- (NSString *) rightButtonTitle { +- (id) rightButtonTitle { return [sections_ count] == 0 ? nil : editing_ ? @"Done" : @"Edit"; } @@ -6362,7 +6403,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return [(CYBook *)book_ updating] ? nil : @"Refresh"; } -- (NSString *) rightButtonTitle { +- (id) rightButtonTitle { return upgrades_ == 0 ? nil : [NSString stringWithFormat:@"Upgrade (%u)", upgrades_]; } diff --git a/exec.mm b/exec.mm deleted file mode 100644 index f53d2cf..0000000 --- a/exec.mm +++ /dev/null @@ -1,66 +0,0 @@ -#include <Foundation/Foundation.h> -#include <CoreFoundation/CoreFoundation.h> - -#include <sys/types.h> -#include <pwd.h> -#include <unistd.h> - -#include <stdio.h> -#include <stdlib.h> - -const char *Firmware_ = NULL; - -unsigned Major_; -unsigned Minor_; -unsigned BugFix_; - -#define FW_LEAST(major, minor, bugfix) \ - (major < Major_ || major == Major_ && \ - (minor < Minor_ || minor == Minor_ && \ - bugfix <= BugFix_)) - -int main(int argc, char *argv[]) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - if (NSDictionary *sysver = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]) { - if (NSString *prover = [sysver valueForKey:@"ProductVersion"]) { - Firmware_ = strdup([prover UTF8String]); - NSArray *versions = [prover componentsSeparatedByString:@"."]; - int count = [versions count]; - Major_ = count > 0 ? [[versions objectAtIndex:0] intValue] : 0; - Minor_ = count > 1 ? [[versions objectAtIndex:1] intValue] : 0; - BugFix_ = count > 2 ? [[versions objectAtIndex:2] intValue] : 0; - } - } - - [pool release]; - - const char *user; - if (FW_LEAST(1,1,3)) - user = "mobile"; - else - user = "root"; - - if (argc == 1) - printf("%s\n", user); - else { - struct passwd *passwd = getpwnam(user); - - if (setreuid(passwd->pw_uid, 0) == -1) { - perror("setreuid"); - exit(1); - } - - if (setregid(passwd->pw_gid, 0) == -1) { - perror("setregid"); - exit(1); - } - - if (execvp(argv[1], argv + 1) == -1) { - perror("execvp"); - exit(1); - } - } - - return 0; -} @@ -1,2 +1,2 @@ #!/bin/bash -PATH=/apl/n42/pre/bin:$PATH exec /apl/tel/exec.sh cydia make "$@" +PATH=/apl/n42/pre/bin:$PATH exec /apl/tel/exec.sh :apt:pcre make "$@" @@ -4,16 +4,13 @@ else target := $(PKG_TARG)- endif -all: Cydia exec +all: Cydia clean: - rm -f Cydia exec + rm -f Cydia -exec: exec.mm makefile - $(target)g++ -Wall -Werror -o $@ $< -framework Foundation -framework CoreFoundation -lobjc - -Cydia: Cydia.mm ../uicaboodle.m/*.mm *.h makefile - $(target)g++ -march=armv6 -mcpu=arm1176jzf-s -I../uicaboodle.m -fobjc-call-cxx-cdtors -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework IOKit -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework GraphicsServices -framework MessageUI -framework QuartzCore -framework WebKit -framework JavaScriptCore -lobjc -lapt-pkg -lpcre -fobjc-exceptions -F"$${PKG_ROOT}"/System/Library/PrivateFrameworks +Cydia: Cydia.mm ../uicaboodle.m/*.mm ../mobilesubstrate/*.h *.h makefile + $(target)g++ -march=armv6 -mcpu=arm1176jzf-s -I../uicaboodle.m -I../mobilesubstrate -fobjc-call-cxx-cdtors -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework IOKit -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework GraphicsServices -framework MessageUI -framework QuartzCore -framework JavaScriptCore -framework WebCore -framework WebKit -lobjc -lapt-pkg -lpcre -fobjc-exceptions -F"$${PKG_ROOT}"/System/Library/PrivateFrameworks -multiply_defined suppress sign: Cydia CODESIGN_ALLOCATE=$$(which "$(target)codesign_allocate") /apl/tel/util/ldid -Slaunch.xml Cydia |