--- /dev/null
+Tagline = "represents the lack of any cydget display";
+Tagline = "particularly lame example for you to remove";
Plugin = "WebCycriptLockScreen";
Configuration = {
--- /dev/null
+items = ({
+ cell = PSGroupCell;
+}, {
+ cell = PSLinkCell;
+ detail = CydgetOrderController;
+ icon = LockCydgets.png;
+ label = "Lock Cydget Order";
+});
+
+title = Cydget;
--- /dev/null
+<?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>
-/* WinterBoard - Theme Manager for the iPhone
+/* CydgetScript - open-source IntelliDial replacement
* Copyright (C) 2009 Jay Freeman (saurik)
*/
static NSString *_plist;
/* Theme Settings Controller {{{ */
-@interface WBSThemesController: PSViewController <UITableViewDelegate, UITableViewDataSource> {
+@interface CydgetOrderController: PSViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *_tableView;
NSMutableArray *_themes;
}
@end
-@implementation WBSThemesController
+@implementation CydgetOrderController
@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) {
- self.themes = [_settings objectForKey:@"Themes"];
+ self.themes = [_settings objectForKey:@"LockCydgets"];
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++) {
[_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;
}
}
- (id) navigationTitle {
- return @"Themes";
+ return @"Lock Cydgets";
}
- (id) view {
@end
/* }}} */
-@interface WBSettingsController: PSListController {
+@interface CydgetSettingsController: PSListController {
}
- (id) initForContentSize:(CGSize)size;
@end
-@implementation WBSettingsController
+@implementation CydgetSettingsController
- (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;
}
- (id) specifiers {
if (!_specifiers)
- _specifiers = [[self loadSpecifiersFromPlistName:@"WinterBoard" target:self] retain];
+ _specifiers = [[self loadSpecifiersFromPlistName:@"Cydget" target:self] retain];
return _specifiers;
}
}
- (NSString *) title {
- return @"WinterBoard";
+ return @"Cydget";
}
- (void) setPreferenceValue:(id)value specifier:(PSSpecifier *)spec {
}
#lcd h2 {
- font-family: "LockClock-Light";
+ font-family: "Helvetica";
font-size: 17px;
- left: 2px;
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>
-with (Cycript.runtime) {
+with (Cycript.all) {
document.write('<h1>[' + malloc + ']</h1>');
}
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 {
+ [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"));
#import <SpringBoard/SBAwayController.h>
#import <SpringBoard/SBAwayWindow.h>
+#import <SpringBoard/SpringBoard.h>
MSClassHook(SpringBoard)
MSClassHook(SBAwayController)
static bool menu_;
static unsigned lock_;
+static _H<NSArray> settings_;
static _H<NSArray> cydgets_;
-static size_t active_ = _not(size_t);
+static size_t active_;
@interface CydgetController : NSObject {
}
@implementation CydgetController
+ (NSDictionary *) currentConfiguration {
- return active_ == _not(size_t) ? nil : [[cydgets_ objectAtIndex:active_] objectForKey:@"Configuration"];
+ return [[cydgets_ objectAtIndex:active_] objectForKey:@"Configuration"];
}
@end
@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 {
- [away disableLockScreenBundleWithName:[self objectForKey:@"Plugin"]];
+ if (NSString *plugin = [self objectForKey:@"Plugin"])
+ [away disableLockScreenBundleWithName:plugin];
}
@end
-MSHook(BOOL, SBAwayController$handleMenuButtonTap, SBAwayController *self, SEL sel) {
+MSInstanceMessageHook0(BOOL, SBAwayController, handleMenuButtonTap) {
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;
}
-MSHook(void, SBAwayController$_undimScreen, SBAwayController *self, SEL sel) {
+MSInstanceMessageHook0(void, SBAwayController, _undimScreen) {
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;
- _SBAwayController$undimScreen(self, sel);
+ MSOldCall();
}
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);
- _SBAwayController$finishedDimmingScreen(self, sel);
+ MSOldCall();
}
-MSHook(void, SpringBoard$menuButtonUp$, UIView *self, SEL sel, GSEventRef event) {
+MSInstanceMessageHook1(void, SpringBoard, menuButtonUp, GSEventRef, event) {
menu_ = true;
- _SpringBoard$menuButtonUp$(self, sel, event);
+ MSOldCall(event);
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);
}
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)
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
- 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