]> git.saurik.com Git - cydget.git/commitdiff
Checkpoint for Welcome.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 8 Nov 2009 05:27:55 +0000 (05:27 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 8 Nov 2009 05:27:55 +0000 (05:27 +0000)
13 files changed:
AwayView.cydget/Info.plist [new file with mode: 0644]
CydgetCentral.plist
CydgetSettings.bundle/Cydget.plist [new file with mode: 0644]
CydgetSettings.bundle/Info.plist [new file with mode: 0644]
CydgetSettings.bundle/LockCydgets.png [new file with mode: 0644]
CydgetSettings.mm
Icon-Small.png [new file with mode: 0644]
Index.html
Index.js
LockScreen.mm
Tweak.mm
control
makefile

diff --git a/AwayView.cydget/Info.plist b/AwayView.cydget/Info.plist
new file mode 100644 (file)
index 0000000..41e0365
--- /dev/null
@@ -0,0 +1 @@
+Tagline = "represents the lack of any cydget display";
index ba2e841d5d3193639075d3fc6afd3b980d5c25bc..d4cead124d901246aaae2232ec014a4b95296661 100644 (file)
@@ -1,3 +1,4 @@
+Tagline = "particularly lame example for you to remove";
 Plugin = "WebCycriptLockScreen";
 
 Configuration = {
 Plugin = "WebCycriptLockScreen";
 
 Configuration = {
diff --git a/CydgetSettings.bundle/Cydget.plist b/CydgetSettings.bundle/Cydget.plist
new file mode 100644 (file)
index 0000000..9fb3ceb
--- /dev/null
@@ -0,0 +1,10 @@
+items = ({
+    cell = PSGroupCell;
+}, {
+    cell = PSLinkCell;
+    detail = CydgetOrderController;
+    icon = LockCydgets.png;
+    label = "Lock Cydget Order";
+});
+
+title = Cydget;
diff --git a/CydgetSettings.bundle/Info.plist b/CydgetSettings.bundle/Info.plist
new file mode 100644 (file)
index 0000000..334c292
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//GNUstep//DTD plist 0.9//EN" "http://www.gnustep.org/plist-0_9.xml">
+<plist version="0.9">
+<dict>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>en</string>
+    <key>CFBundleExecutable</key>
+    <string>CydgetSettings</string>
+    <key>CFBundleIdentifier</key>
+    <string>com.saurik.winterboard.settings</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundlePackageType</key>
+    <string>BNDL</string>
+    <key>CFBundleShortVersionString</key>
+    <string>0.9</string>
+    <key>CFBundleSignature</key>
+    <string>????</string>
+    <key>CFBundleVersion</key>
+    <string>1.0</string>
+    <key>DTPlatformName</key>
+    <string>iphoneos</string>
+    <key>MinimumOSVersion</key>
+    <string>3.0</string>
+    <key>NSPrincipalClass</key>
+    <string>CydgetSettingsController</string>
+</dict>
+</plist>
diff --git a/CydgetSettings.bundle/LockCydgets.png b/CydgetSettings.bundle/LockCydgets.png
new file mode 100644 (file)
index 0000000..ab4a13c
Binary files /dev/null and b/CydgetSettings.bundle/LockCydgets.png differ
index 5d79fd965a1e4b919d75f408b7afd6fc034cbbf8..dbe5ab74fef996f801c8add6d67be439edbc7310 100644 (file)
@@ -1,4 +1,4 @@
-/* WinterBoard - Theme Manager for the iPhone
+/* CydgetScript - open-source IntelliDial replacement
  * Copyright (C) 2009  Jay Freeman (saurik)
 */
 
  * Copyright (C) 2009  Jay Freeman (saurik)
 */
 
@@ -53,7 +53,7 @@ static NSMutableDictionary *_settings;
 static NSString *_plist;
 
 /* Theme Settings Controller {{{ */
 static NSString *_plist;
 
 /* Theme Settings Controller {{{ */
-@interface WBSThemesController: PSViewController <UITableViewDelegate, UITableViewDataSource> {
+@interface CydgetOrderController: PSViewController <UITableViewDelegate, UITableViewDataSource> {
     UITableView *_tableView;
     NSMutableArray *_themes;
 }
     UITableView *_tableView;
     NSMutableArray *_themes;
 }
@@ -79,51 +79,35 @@ static NSString *_plist;
 
 @end
 
 
 @end
 
-@implementation WBSThemesController
+@implementation CydgetOrderController
 
 @synthesize themes = _themes;
 
 + (void) load {
     NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
     checkImage = [_UIImageWithName(@"UIPreferencesBlueCheck.png") retain];
 
 @synthesize themes = _themes;
 
 + (void) load {
     NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
     checkImage = [_UIImageWithName(@"UIPreferencesBlueCheck.png") retain];
-    uncheckedImage = [[UIImage imageWithContentsOfFile:@"/System/Library/PreferenceBundles/WinterBoardSettings.bundle/SearchResultsCheckmarkClear.png"] retain];
+    uncheckedImage = [[UIImage imageWithContentsOfFile:@"/System/Library/PreferenceBundles/CydgetSettings.bundle/SearchResultsCheckmarkClear.png"] retain];
     [pool release];
 }
 
 - (id) initForContentSize:(CGSize)size {
     if ((self = [super initForContentSize:size]) != nil) {
     [pool release];
 }
 
 - (id) initForContentSize:(CGSize)size {
     if ((self = [super initForContentSize:size]) != nil) {
-        self.themes = [_settings objectForKey:@"Themes"];
+        self.themes = [_settings objectForKey:@"LockCydgets"];
         if (!_themes) {
         if (!_themes) {
-            if (NSString *theme = [_settings objectForKey:@"Theme"]) {
-                self.themes = [NSMutableArray arrayWithObject:
-                         [NSMutableDictionary dictionaryWithObjectsAndKeys:
-                                            theme, @"Name",
-                                [NSNumber numberWithBool:YES], @"Active", nil]];
-                [_settings removeObjectForKey:@"Theme"];
-            }
-            if (!_themes)
-                self.themes = [NSMutableArray array];
-            [_settings setObject:_themes forKey:@"Themes"];
-        }
-
-        NSMutableArray *themesOnDisk([NSMutableArray array]);
+            self.themes = [NSMutableArray arrayWithObjects:[NSMutableDictionary dictionaryWithObjectsAndKeys:
+                @"AwayView", @"Name", [NSNumber numberWithBool:YES], @"Active", nil
+            ], [NSMutableDictionary dictionaryWithObjectsAndKeys:
+                @"CydgetCentral", @"Name", [NSNumber numberWithBool:YES], @"Active", nil
+            ], nil];
 
 
-        [themesOnDisk
-            addObjectsFromArray:[[NSFileManager defaultManager]
-            contentsOfDirectoryAtPath:@"/Library/Themes" error:NULL]
-        ];
-
-        [themesOnDisk addObjectsFromArray:[[NSFileManager defaultManager]
-            contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()]
-            error:NULL
-        ]];
-
-        for (int i = 0, count = [themesOnDisk count]; i < count; i++) {
-            NSString *theme = [themesOnDisk objectAtIndex:i];
-            if ([theme hasSuffix:@".theme"])
-                [themesOnDisk replaceObjectAtIndex:i withObject:[theme stringByDeletingPathExtension]];
+            [_settings setObject:_themes forKey:@"LockCydgets"];
         }
 
         }
 
+        NSMutableArray *themesOnDisk([NSMutableArray arrayWithCapacity:4]);
+        for (NSString *theme in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/System/Library/LockCydgets" error:NULL])
+            if ([theme hasSuffix:@".cydget"])
+                [themesOnDisk addObject:[theme stringByDeletingPathExtension]];
+
         NSMutableSet *themesSet([NSMutableSet set]);
 
         for (int i = 0, count = [_themes count]; i < count; i++) {
         NSMutableSet *themesSet([NSMutableSet set]);
 
         for (int i = 0, count = [_themes count]; i < count; i++) {
@@ -155,7 +139,7 @@ static NSString *_plist;
         [_tableView setDelegate:self];
         [_tableView setEditing:YES];
         [_tableView setAllowsSelectionDuringEditing:YES];
         [_tableView setDelegate:self];
         [_tableView setEditing:YES];
         [_tableView setAllowsSelectionDuringEditing:YES];
-        [self showLeftButton:@"WinterBoard" withStyle:1 rightButton:nil withStyle:0];
+        [self showLeftButton:@"Cydget" withStyle:1 rightButton:nil withStyle:0];
     }
     return self;
 }
     }
     return self;
 }
@@ -167,7 +151,7 @@ static NSString *_plist;
 }
 
 - (id) navigationTitle {
 }
 
 - (id) navigationTitle {
-    return @"Themes";
+    return @"Lock Cydgets";
 }
 
 - (id) view {
 }
 
 - (id) view {
@@ -244,7 +228,7 @@ static NSString *_plist;
 @end
 /* }}} */
 
 @end
 /* }}} */
 
-@interface WBSettingsController: PSListController {
+@interface CydgetSettingsController: PSListController {
 }
 
 - (id) initForContentSize:(CGSize)size;
 }
 
 - (id) initForContentSize:(CGSize)size;
@@ -261,11 +245,11 @@ static NSString *_plist;
 
 @end
 
 
 @end
 
-@implementation WBSettingsController
+@implementation CydgetSettingsController
 
 - (id) initForContentSize:(CGSize)size {
     if ((self = [super initForContentSize:size]) != nil) {
 
 - (id) initForContentSize:(CGSize)size {
     if ((self = [super initForContentSize:size]) != nil) {
-        _plist = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()] retain];
+        _plist = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Cydget.plist", NSHomeDirectory()] retain];
         _settings = [([NSMutableDictionary dictionaryWithContentsOfFile:_plist] ?: [NSMutableDictionary dictionary]) retain];
     } return self;
 }
         _settings = [([NSMutableDictionary dictionaryWithContentsOfFile:_plist] ?: [NSMutableDictionary dictionary]) retain];
     } return self;
 }
@@ -322,7 +306,7 @@ static NSString *_plist;
 
 - (id) specifiers {
     if (!_specifiers)
 
 - (id) specifiers {
     if (!_specifiers)
-        _specifiers = [[self loadSpecifiersFromPlistName:@"WinterBoard" target:self] retain];
+        _specifiers = [[self loadSpecifiersFromPlistName:@"Cydget" target:self] retain];
     return _specifiers;
 }
 
     return _specifiers;
 }
 
@@ -332,7 +316,7 @@ static NSString *_plist;
 }
 
 - (NSString *) title {
 }
 
 - (NSString *) title {
-    return @"WinterBoard";
+    return @"Cydget";
 }
 
 - (void) setPreferenceValue:(id)value specifier:(PSSpecifier *)spec {
 }
 
 - (void) setPreferenceValue:(id)value specifier:(PSSpecifier *)spec {
diff --git a/Icon-Small.png b/Icon-Small.png
new file mode 100644 (file)
index 0000000..2c69f11
Binary files /dev/null and b/Icon-Small.png differ
index 33f98a5b593aa3c1d7726d8e1e5137b9829d11f4..575778250ee609628b372359a067d9fbebcb70cd 100644 (file)
     }
 
     #lcd h2 {
     }
 
     #lcd h2 {
-        font-family: "LockClock-Light";
+        font-family: "Helvetica";
         font-size: 17px;
         font-size: 17px;
-        left: 2px;
         position: relative;
         text-align: center;
         text-shadow: -0.5px -1px 1px black;
         top: -16px;
     }
 </style></head><body>
         position: relative;
         text-align: center;
         text-shadow: -0.5px -1px 1px black;
         top: -16px;
     }
 </style></head><body>
-    <div id="lcd">
-        <h1><script type="text/javascript">with (Cycript.all) {
-            var locale = CFLocaleCopyCurrent();
-            var formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
-            CFRelease(locale);
-            var format = UIDateFormatStringForFormatType(UINoAMPMTimeFormat);
-            CFDateFormatterSetFormat(formatter, format);
-            var now = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
-            var string = CFDateFormatterCreateStringWithDate(NULL, formatter, now);
-            CFRelease(formatter);
-            document.write(string);
-            CFRelease(string);
-        }</script></h1>
+    <!-- XXX: extract this out to some kind of nifty Lock Cydget library -->
+    <div id="lcd"><script type="text/javascript">with (Cycript.all) {
+        var locale = CFLocaleCopyCurrent();
+        var now = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
+        var formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
+        CFRelease(locale);
+
+        CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UINoAMPMTimeFormat));
+        var time = CFDateFormatterCreateStringWithDate(NULL, formatter, now);
+        document.write('<h1>' + time + '</h1>');
+        CFRelease(time);
+
+        CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UIWeekdayNoYearDateFormat));
+        var date = CFDateFormatterCreateStringWithDate(NULL, formatter, now);
+        document.write('<h2>' + date + '</h2>');
+        CFRelease(date);
 
 
-        <h2>Lock Cydget Example</h2>
-    </div>
+        CFRelease(formatter);
+        CFRelease(now);
+    }</script></div>
 
     <script type="text/javascript" src="Index.js"></script>
 </body></html>
 
     <script type="text/javascript" src="Index.js"></script>
 </body></html>
index 4d0729589072371318cc88023cb436bda3d21316..315a3b15a67fde19078c6f37871390985865eb0b 100644 (file)
--- a/Index.js
+++ b/Index.js
@@ -1,3 +1,3 @@
-with (Cycript.runtime) {
+with (Cycript.all) {
     document.write('<h1>[' + malloc + ']</h1>');
 }
     document.write('<h1>[' + malloc + ']</h1>');
 }
index 76c6cdc474f726af1cbf7fca9a9fa318b3c1af2c..f1963e73bcf61f87cf3dea78fe9b06fc7558f04a 100644 (file)
@@ -717,9 +717,82 @@ MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::Parse
     return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, data, line, message);
 }*/
 
     return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, data, line, message);
 }*/
 
+/* Cydget:// Protocol {{{ */
+@interface CydgetURLProtocol : NSURLProtocol {
+}
+
+@end
+
+@implementation CydgetURLProtocol
+
++ (BOOL) canInitWithRequest:(NSURLRequest *)request {
+    NSURL *url([request URL]);
+    if (url == nil)
+        return NO;
+    NSString *scheme([[url scheme] lowercaseString]);
+    if (scheme == nil || ![scheme isEqualToString:@"cydget"])
+        return NO;
+    return YES;
+}
+
++ (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
+    return request;
+}
+
+- (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
+    id<NSURLProtocolClient> client([self client]);
+    if (icon == nil)
+        [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
+    else {
+        NSData *data(UIImagePNGRepresentation(icon));
+
+        NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
+        [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
+        [client URLProtocol:self didLoadData:data];
+        [client URLProtocolDidFinishLoading:self];
+    }
+}
+
+- (void) startLoading {
+    id<NSURLProtocolClient> client([self client]);
+    NSURLRequest *request([self request]);
+
+    NSURL *url([request URL]);
+    NSString *href([url absoluteString]);
+
+    NSString *path([href substringFromIndex:9]);
+    NSRange slash([path rangeOfString:@"/"]);
+
+    NSString *command;
+    if (slash.location == NSNotFound) {
+        command = path;
+        path = nil;
+    } else {
+        command = [path substringToIndex:slash.location];
+        path = [path substringFromIndex:(slash.location + 1)];
+    }
+
+    if ([command isEqualToString:@"_UIImageWithName"]) {
+        if (path == nil)
+            goto fail;
+        path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        UIImage *icon(_UIImageWithName(path));
+        [self _returnPNGWithImage:icon forRequest:request];
+    } else fail: {
+        [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
+    }
+}
+
+- (void) stopLoading {
+}
+
+@end
+/* }}} */
+
 @implementation WebCycriptLockScreenController
 
 + (void) initialize {
 @implementation WebCycriptLockScreenController
 
 + (void) initialize {
+    [NSURLProtocol registerClass:[CydgetURLProtocol class]];
     //MSHookFunction(&_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
     if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
         CYSetupContext = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CYSetupContext"));
     //MSHookFunction(&_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
     if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
         CYSetupContext = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CYSetupContext"));
index 6702a7ffc2ab4b6a010fe3213487f1a69a041300..cd25dfd6d10f64f5a46903614bddcd45d4cfe52b 100644 (file)
--- a/Tweak.mm
+++ b/Tweak.mm
@@ -43,6 +43,7 @@
 
 #import <SpringBoard/SBAwayController.h>
 #import <SpringBoard/SBAwayWindow.h>
 
 #import <SpringBoard/SBAwayController.h>
 #import <SpringBoard/SBAwayWindow.h>
+#import <SpringBoard/SpringBoard.h>
 
 MSClassHook(SpringBoard)
 MSClassHook(SBAwayController)
 
 MSClassHook(SpringBoard)
 MSClassHook(SBAwayController)
@@ -56,8 +57,9 @@ MSClassHook(SBAwayView)
 static bool menu_;
 static unsigned lock_;
 
 static bool menu_;
 static unsigned lock_;
 
+static _H<NSArray> settings_;
 static _H<NSArray> cydgets_;
 static _H<NSArray> cydgets_;
-static size_t active_ = _not(size_t);
+static size_t active_;
 
 @interface CydgetController : NSObject {
 }
 
 @interface CydgetController : NSObject {
 }
@@ -69,7 +71,7 @@ static size_t active_ = _not(size_t);
 @implementation CydgetController
 
 + (NSDictionary *) currentConfiguration {
 @implementation CydgetController
 
 + (NSDictionary *) currentConfiguration {
-    return active_ == _not(size_t) ? nil : [[cydgets_ objectAtIndex:active_] objectForKey:@"Configuration"];
+    return [[cydgets_ objectAtIndex:active_] objectForKey:@"Configuration"];
 }
 
 @end
 }
 
 @end
@@ -82,160 +84,90 @@ static size_t active_ = _not(size_t);
 @implementation NSDictionary (Cydgets)
 
 - (void) enableCydget:(SBAwayController *)away {
 @implementation NSDictionary (Cydgets)
 
 - (void) enableCydget:(SBAwayController *)away {
-    [away enableLockScreenBundleWithName:[self objectForKey:@"Plugin"]];
+    if (NSString *plugin = [self objectForKey:@"Plugin"])
+        [away enableLockScreenBundleWithName:plugin];
 }
 
 - (void) disableCydget:(SBAwayController *)away {
 }
 
 - (void) disableCydget:(SBAwayController *)away {
-    [away disableLockScreenBundleWithName:[self objectForKey:@"Plugin"]];
+    if (NSString *plugin = [self objectForKey:@"Plugin"])
+        [away disableLockScreenBundleWithName:plugin];
 }
 
 @end
 
 }
 
 @end
 
-MSHook(BOOL, SBAwayController$handleMenuButtonTap, SBAwayController *self, SEL sel) {
+MSInstanceMessageHook0(BOOL, SBAwayController, handleMenuButtonTap) {
     unsigned lock(lock_);
 
     unsigned lock(lock_);
 
-    if (!_SBAwayController$handleMenuButtonTap(self, sel) && lock != 2) {
-        if (active_ != _not(size_t))
-            [[cydgets_ objectAtIndex:active_] disableCydget:self];
-
-        size_t count([cydgets_ count]);
-        if ((++active_ %= count + 1) == count)
-            active_ = _not(size_t);
-        else
-            [[cydgets_ objectAtIndex:active_] enableCydget:self];
+    if (!MSOldCall() && lock != 2) {
+        [[cydgets_ objectAtIndex:active_] disableCydget:self];
+        active_ = (active_ + 1) % [cydgets_ count];
+        [[cydgets_ objectAtIndex:active_] enableCydget:self];
     }
 
     return YES;
 }
 
     }
 
     return YES;
 }
 
-MSHook(void, SBAwayController$_undimScreen, SBAwayController *self, SEL sel) {
+MSInstanceMessageHook0(void, SBAwayController, _undimScreen) {
     if (lock_ == 1)
         lock_ = 2;
     if (lock_ == 1)
         lock_ = 2;
-    _SBAwayController$_undimScreen(self, sel);
+    [[cydgets_ objectAtIndex:active_] enableCydget:[$SBAwayController sharedAwayController]];
+    MSOldCall();
 }
 
 }
 
-MSHook(void, SBAwayController$undimScreen, SBAwayController *self, SEL sel) {
+MSInstanceMessageHook0(void, SBAwayController, undimScreen) {
     lock_ = menu_ ? 1 : 0;
     lock_ = menu_ ? 1 : 0;
-    _SBAwayController$undimScreen(self, sel);
+    MSOldCall();
 }
 
 static void Deactivate_(SBAwayController *self) {
 }
 
 static void Deactivate_(SBAwayController *self) {
-    if (active_ != _not(size_t)) {
-        [[cydgets_ objectAtIndex:active_] disableCydget:self];
-        active_ = _not(size_t);
-    }
+    [[cydgets_ objectAtIndex:active_] disableCydget:self];
+    active_ = 0;
 }
 
 }
 
-MSHook(void, SBAwayController$finishedDimmingScreen, SBAwayController *self, SEL sel) {
+MSInstanceMessageHook0(void, SBAwayController, finishedDimmingScreen) {
     Deactivate_(self);
     Deactivate_(self);
-    _SBAwayController$finishedDimmingScreen(self, sel);
+    MSOldCall();
 }
 
 }
 
-MSHook(void, SpringBoard$menuButtonUp$, UIView *self, SEL sel, GSEventRef event) {
+MSInstanceMessageHook1(void, SpringBoard, menuButtonUp, GSEventRef, event) {
     menu_ = true;
     menu_ = true;
-    _SpringBoard$menuButtonUp$(self, sel, event);
+    MSOldCall(event);
     menu_ = false;
 }
 
     menu_ = false;
 }
 
-MSHook(void, SBAwayView$addGestureRecognizer$, UIView *self, SEL sel, id gr) {
-    //_SBAwayView$addGestureRecognizer$(self, sel, gr);
-}
-
-MSInstanceMessageHook1(void, SBAwayController, _finishedUnlockAttemptWithStatus, BOOL, status) {
-    if (status)
-        Deactivate_(self);
-    MSOldCall(status);
-}
-
-/* Cydget:// Protocol {{{ */
-@interface CydgetURLProtocol : NSURLProtocol {
-}
-
-@end
-
-@implementation CydgetURLProtocol
-
-+ (BOOL) canInitWithRequest:(NSURLRequest *)request {
-    NSURL *url([request URL]);
-    if (url == nil)
-        return NO;
-    NSString *scheme([[url scheme] lowercaseString]);
-    if (scheme == nil || ![scheme isEqualToString:@"cydget"])
-        return NO;
-    return YES;
-}
-
-+ (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
-    return request;
-}
-
-- (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
-    id<NSURLProtocolClient> client([self client]);
-    if (icon == nil)
-        [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
-    else {
-        NSData *data(UIImagePNGRepresentation(icon));
-
-        NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
-        [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
-        [client URLProtocol:self didLoadData:data];
-        [client URLProtocolDidFinishLoading:self];
-    }
+MSInstanceMessageHook1(void, SBAwayView, addGestureRecognizer, id, recognizer) {
+    // MSOldCall(recognizer);
 }
 
 }
 
-- (void) startLoading {
-    id<NSURLProtocolClient> client([self client]);
-    NSURLRequest *request([self request]);
-
-    NSURL *url([request URL]);
-    NSString *href([url absoluteString]);
+#define Cydgets_ @"/System/Library/LockCydgets"
 
 
-    NSString *path([href substringFromIndex:9]);
-    NSRange slash([path rangeOfString:@"/"]);
+static void CydgetSetup() {
+    NSString *plist([NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Cydget.plist", NSHomeDirectory()]);
+    settings_ = [NSMutableDictionary dictionaryWithContentsOfFile:plist] ?: [NSMutableDictionary dictionary];
 
 
-    NSString *command;
-    if (slash.location == NSNotFound) {
-        command = path;
-        path = nil;
-    } else {
-        command = [path substringToIndex:slash.location];
-        path = [path substringFromIndex:(slash.location + 1)];
-    }
+    NSArray *cydgets([settings_ objectForKey:@"LockCydgets"] ?: [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
+        @"AwayView", @"Name", [NSNumber numberWithBool:YES], @"Active", nil
+    ], [NSDictionary dictionaryWithObjectsAndKeys:
+        @"CydgetCentral", @"Name", [NSNumber numberWithBool:YES], @"Active", nil
+    ], nil]);
 
 
-    if ([command isEqualToString:@"_UIImageWithName"]) {
-        if (path == nil)
-            goto fail;
-        path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-        UIImage *icon(_UIImageWithName(path));
-        [self _returnPNGWithImage:icon forRequest:request];
-    } else fail: {
-        [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
-    }
+    cydgets_ = [NSMutableArray arrayWithCapacity:4];
+    for (NSDictionary *cydget in cydgets)
+        if ([[cydget objectForKey:@"Active"] boolValue])
+            if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.cydget/Info.plist", Cydgets_, [cydget objectForKey:@"Name"]]])
+                [cydgets_ addObject:info];
 }
 
 }
 
-- (void) stopLoading {
+// XXX: this could happen while it is unlocked
+MSInstanceMessageHook1(id, SBAwayView, initWithFrame, CGRect, frame) {
+    self = MSOldCall(frame);
+    CydgetSetup();
+    [[cydgets_ objectAtIndex:active_] enableCydget:[$SBAwayController sharedAwayController]];
+    return self;
 }
 
 }
 
-@end
-/* }}} */
-
-#define Cydgets_ @"/System/Library/LockCydgets"
-
-MSInitialize { _pooled
-    [NSURLProtocol registerClass:[CydgetURLProtocol class]];
-
-    cydgets_ = [NSMutableArray arrayWithCapacity:4];
-
-    for (NSString *folder in [[NSFileManager defaultManager] directoryContentsAtPath:Cydgets_])
-        if ([folder hasSuffix:@".cydget"])
-            [cydgets_ addObject:[NSDictionary dictionaryWithContentsOfFile:[[Cydgets_ stringByAppendingPathComponent:folder] stringByAppendingPathComponent:@"Info.plist"]]];
-
-    MSHookMessage1(SpringBoard, menuButtonUp);
-
-    MSHookMessage0(SBAwayController, handleMenuButtonTap);
-    MSHookMessage0(SBAwayController, _undimScreen);
-    MSHookMessage0(SBAwayController, undimScreen);
-    MSHookMessage0(SBAwayController, finishedDimmingScreen);
-
-    MSHookMessage1(SBAwayView, addGestureRecognizer);
+MSInstanceMessageHook1(void, SBAwayController, _finishedUnlockAttemptWithStatus, BOOL, status) {
+    if (status)
+        Deactivate_(self);
+    MSOldCall(status);
 }
 }
diff --git a/control b/control
index 159e3be89f2cd31d0346775860db97a2b9ecd3ee..e100ed2e6b97be17fbb5286e46f66bc0db19336b 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.3076-1
+Version: 0.9.3079-1
 Description: framework for managing lock screen plugins
 Name: Cydget
 Depends: mobilesubstrate (>= 0.9.2587-1), cycript (>= 0.9.252)
 Description: framework for managing lock screen plugins
 Name: Cydget
 Depends: mobilesubstrate (>= 0.9.2587-1), cycript (>= 0.9.252)
index f88b187595984a6ae0d4871ebd3c1d7775a262f5..21080603334523207fe4f6afd70efaac34aed968 100644 (file)
--- a/makefile
+++ b/makefile
@@ -22,12 +22,13 @@ extra:
        mkdir -p package/System/Library/LockCydgets/CydgetCentral.cydget
        cp -a Index.{html,js} package/System/Library/LockCydgets/CydgetCentral.cydget
        cp -a CydgetCentral.plist package/System/Library/LockCydgets/CydgetCentral.cydget/Info.plist
        mkdir -p package/System/Library/LockCydgets/CydgetCentral.cydget
        cp -a Index.{html,js} package/System/Library/LockCydgets/CydgetCentral.cydget
        cp -a CydgetCentral.plist package/System/Library/LockCydgets/CydgetCentral.cydget/Info.plist
+       svn export AwayView.cydget package/System/Library/LockCydgets/AwayView.cydget
        mkdir -p package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
        cp -a Info.plist package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
        cp -a WebCycriptLockScreen package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
        mkdir -p package/Library/PreferenceLoader/Preferences
        mkdir -p package/System/Library/PreferenceBundles
        cp -a CydgetSettings.plist package/Library/PreferenceLoader/Preferences
        mkdir -p package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
        cp -a Info.plist package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
        cp -a WebCycriptLockScreen package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle
        mkdir -p package/Library/PreferenceLoader/Preferences
        mkdir -p package/System/Library/PreferenceBundles
        cp -a CydgetSettings.plist package/Library/PreferenceLoader/Preferences
-       cp -a CydgetSettings.bundle package/System/Library/PreferenceBundles
+       svn export CydgetSettings.bundle package/System/Library/PreferenceBundles/CydgetSettings.bundle
        cp -a Icon-Small.png package/System/Library/PreferenceBundles/CydgetSettings.bundle/icon.png
        cp -a SearchResultsCheckmarkClear.png CydgetSettings package/System/Library/PreferenceBundles/CydgetSettings.bundle
        cp -a Icon-Small.png package/System/Library/PreferenceBundles/CydgetSettings.bundle/icon.png
        cp -a SearchResultsCheckmarkClear.png CydgetSettings package/System/Library/PreferenceBundles/CydgetSettings.bundle