From 3a0081b3c433c6cc24d8e6133adf6822ce503bfa Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 8 Nov 2009 05:27:55 +0000 Subject: [PATCH] Checkpoint for Welcome. --- AwayView.cydget/Info.plist | 1 + CydgetCentral.plist | 1 + CydgetSettings.bundle/Cydget.plist | 10 ++ CydgetSettings.bundle/Info.plist | 28 +++++ CydgetSettings.bundle/LockCydgets.png | Bin 0 -> 1055 bytes CydgetSettings.mm | 62 ++++------ Icon-Small.png | Bin 0 -> 2515 bytes Index.html | 37 +++--- Index.js | 2 +- LockScreen.mm | 73 +++++++++++ Tweak.mm | 168 ++++++++------------------ control | 2 +- makefile | 3 +- 13 files changed, 210 insertions(+), 177 deletions(-) create mode 100644 AwayView.cydget/Info.plist create mode 100644 CydgetSettings.bundle/Cydget.plist create mode 100644 CydgetSettings.bundle/Info.plist create mode 100644 CydgetSettings.bundle/LockCydgets.png create mode 100644 Icon-Small.png diff --git a/AwayView.cydget/Info.plist b/AwayView.cydget/Info.plist new file mode 100644 index 0000000..41e0365 --- /dev/null +++ b/AwayView.cydget/Info.plist @@ -0,0 +1 @@ +Tagline = "represents the lack of any cydget display"; diff --git a/CydgetCentral.plist b/CydgetCentral.plist index ba2e841..d4cead1 100644 --- a/CydgetCentral.plist +++ b/CydgetCentral.plist @@ -1,3 +1,4 @@ +Tagline = "particularly lame example for you to remove"; Plugin = "WebCycriptLockScreen"; Configuration = { diff --git a/CydgetSettings.bundle/Cydget.plist b/CydgetSettings.bundle/Cydget.plist new file mode 100644 index 0000000..9fb3ceb --- /dev/null +++ b/CydgetSettings.bundle/Cydget.plist @@ -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 index 0000000..334c292 --- /dev/null +++ b/CydgetSettings.bundle/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + CydgetSettings + CFBundleIdentifier + com.saurik.winterboard.settings + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 0.9 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + DTPlatformName + iphoneos + MinimumOSVersion + 3.0 + NSPrincipalClass + CydgetSettingsController + + diff --git a/CydgetSettings.bundle/LockCydgets.png b/CydgetSettings.bundle/LockCydgets.png new file mode 100644 index 0000000000000000000000000000000000000000..ab4a13c75cc3b6bd50ee1c620e5d9233bf4191f9 GIT binary patch literal 1055 zcmV+)1mOFLP)n&-Bz7#aVA~ZSkYLeOxT zXY-^tGxwf3_s*Gt#|$$wGxOHm+}!82S}h5xK3minLpnVYPXIuS0Me1cbVTfz0EqOKzePaRA|mWBm6-mMwi6Ik4Yimf zrXY>v7Pm(L1C**hp=&DCKSUs8gwv-lzIycdIrrZCA5ke5(PWCN-+uY;S64n>R1r`W zR4vWz8e`Zh?ojiUM8Xip=joAL`179)ZvI{5i!0xJa&vJV!zM4DO!M1cclqGM*?Zr8 z|LLWu2dpBZi1?8#YT2$;`1SS%JM}tdfHGJktZh`tt#9$e!XK>XD_|U}8;4k3FOoiz z9zQ&iITiJQwWw-qv8oWdkn~8BC!a{;f&nA|o_Q+6%jcdW2t&@kAYdSHA(!-dO66UA z-?s{2HR=NqX~~yLB@wsHk2jVE%l;5dpPj^li%K9CV@%7jj4>n<9!U$cmycns#s=#b zB5-E|P>qgZGjUUa=%0{GD9NO4H0bbP45X4#u7(kHnFJV#&at(F9mC!P3{6or`q3qU z0gEqfAOws-B!nR9wInbNWT54`waKY7 zuUwtK@!9dCI*=2_LBz1MvdiT+&cCg|4sf0Jd(YK_x>KuIYllw2T6tjmdz0>+WWja`#l5?F59+^|Oi7xU2oRgjeDqHtA@2utPevt8k(C>(9_66^#UQse$XN8AkVZWRIRyJDBLX<*1mq2k`{=6*bk0?$b%j) Z{s&KiJthJV<(vQj002ovPDHLkV1ghY^Wp#i literal 0 HcmV?d00001 diff --git a/CydgetSettings.mm b/CydgetSettings.mm index 5d79fd9..dbe5ab7 100644 --- a/CydgetSettings.mm +++ b/CydgetSettings.mm @@ -1,4 +1,4 @@ -/* WinterBoard - Theme Manager for the iPhone +/* CydgetScript - open-source IntelliDial replacement * Copyright (C) 2009 Jay Freeman (saurik) */ @@ -53,7 +53,7 @@ static NSMutableDictionary *_settings; static NSString *_plist; /* Theme Settings Controller {{{ */ -@interface WBSThemesController: PSViewController { +@interface CydgetOrderController: PSViewController { UITableView *_tableView; NSMutableArray *_themes; } @@ -79,51 +79,35 @@ static NSString *_plist; @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++) { @@ -155,7 +139,7 @@ static NSString *_plist; [_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; } @@ -167,7 +151,7 @@ static NSString *_plist; } - (id) navigationTitle { - return @"Themes"; + return @"Lock Cydgets"; } - (id) view { @@ -244,7 +228,7 @@ static NSString *_plist; @end /* }}} */ -@interface WBSettingsController: PSListController { +@interface CydgetSettingsController: PSListController { } - (id) initForContentSize:(CGSize)size; @@ -261,11 +245,11 @@ static NSString *_plist; @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; } @@ -322,7 +306,7 @@ static NSString *_plist; - (id) specifiers { if (!_specifiers) - _specifiers = [[self loadSpecifiersFromPlistName:@"WinterBoard" target:self] retain]; + _specifiers = [[self loadSpecifiersFromPlistName:@"Cydget" target:self] retain]; return _specifiers; } @@ -332,7 +316,7 @@ static NSString *_plist; } - (NSString *) title { - return @"WinterBoard"; + return @"Cydget"; } - (void) setPreferenceValue:(id)value specifier:(PSSpecifier *)spec { diff --git a/Icon-Small.png b/Icon-Small.png new file mode 100644 index 0000000000000000000000000000000000000000..2c69f11bafcb02a59feb86e7e3cf314863d806f2 GIT binary patch literal 2515 zcmV;^2`u)BP)!Dcv|B%d-6J)N~I(1Ngp1YmY}C`#Py{D5V(ej9Pul!P~jPc=e$j zZ)vN4DT;z9)O`BByI1BkfaiHA5t71SKX?mkYavmfDMZoE46Zb!NlMa9=*2l%l4DDY zQi7)x(swd~Lm@b8!8#DZ_cYE}mKHl4J@#Av^bZzU9WA|lN*TDzD#gxAMp!=-@Y~d~ z|M)zfby(+7I3FVxFA@SkoFERA5^xSzTAX!&1qYt;h?A6)CtJ+TE|ByxJkP^9cRm17 zeE`lmdT~lK@(HzLI8Y?LoH8pZGef-8Az6x1PS6@$Zt#5{(cpOsr93?GP*zb`!_xc$ zXD4S#lNjao|8ekU07}##)PJ|;+!(guz3jztgn$uh|P0~v|!8V0zpF&c#6ZXE|B~0 zz>$IRkx-%X5|GvVpU(jiMG;h3fAI((xbh;pa|H*Ew8)Lc^?GCrUCK_EGU?&+0+aT@ zXzALIm8ZAgE;yh!U(Zocm3SAsukZ zrE76nNpH48*~uun8Lk8|g0hyY!xml<6GUqm2}AtJ`DSDv?`iiE&I?UWTzW=l1EOs-V{hv1|PM@RGhusg8DY$2oiiI>fo6A?Vm|-T>pA_sFYwqyd$6Sg zCx~@eYdCb|IIY$sT5Ec}9-U4HV+_U^ih&1=F{Eiqnx-U4LZ{OOpxf>8o$r2+v1W6{ z1qxPGF6SuXm~~@y0R|bWy2Ng-mHYqTAXu;2!5r?SD$!+UU`t0 zPtM_a3UNSL;GD4QgYWL^zO^eg#9B+OR^xwPKE}bH9%akM4gC2{e}=V|JkN>a1g$mJ z#_YM{b|#KbNVQg91;DvJDiOS>&VeJRP+Aj)0m}2S4nDpa_TIXKFsu;AG1gj?Qj|qO z7=}E5=%+mN+JL772F=EDL$Ypd%$l)_=yWP}Xsy@kK9L;8I!5Xdw_d#g?W>jYyv)z);xQ_f{^?Cw zB0v!ML{Wt>2-t8@z{T$z#uf1PdHwsGRb3EX>c z7yzh|rYYLjSm#h8{P@rzjvYH@=jP^KR)bWs&N+utgi&OJuwuigYOA%n9U307wUH5f z&%S-^xalSizVHHLV`D_sh@vR_Bo$$Ne4Gz${}40N)2zRIoU8umDx9?hK|oO&M1&}c zc&G(g2Od=#HuBnS|*XF0|#8nVFeUk3RaZmC4CTwfC;OXf#Gh zk{)GQ5(GY3Rt%(AD2f7rAPnjCQj9SxozO3j9xZn5x;b55UsmVj@3UI1))*NX`Sr}q z%-SCuIKZ}T+lb?MMgK(P*rWoh~Y|AI^z4vn;-nn!8{;xkdlBOxMv$Hto z2!a5mRR6MJ9YtC8i`nu8MuZ>;2*VKP97&Sk`#!BRt;85pF7Kx<1aR%O*LpYJcw;y| zK0dT_=gxa?{fpaf_B?N-R% zllvUkbJ=B= zeR$KRO_4DMC4$zPr=EI>ty{OUrr9J-Qy%}?kwRTY{_3MKN5Bf=x1ns3I>-)hu5rVQT zy&XGuMrT?rnK*HRxYKb%m8h-T%UgrfYqh|WsDhj&NY=%4WQm?wJJdn z1dT>R4=$;$EXx=$&bcKKSt!eLac*vIK}5Ry_wP?1e)wT~;o|>q9T<3J^|L(Z29M=! duc&Wt{|AO}&1E6eZs`C3002ovPDHLkV1kTG=%)Yx literal 0 HcmV?d00001 diff --git a/Index.html b/Index.html index 33f98a5..5757782 100644 --- a/Index.html +++ b/Index.html @@ -41,31 +41,34 @@ } #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; } -
-

+ +
diff --git a/Index.js b/Index.js index 4d07295..315a3b1 100644 --- a/Index.js +++ b/Index.js @@ -1,3 +1,3 @@ -with (Cycript.runtime) { +with (Cycript.all) { document.write('

[' + malloc + ']

'); } diff --git a/LockScreen.mm b/LockScreen.mm index 76c6cdc..f1963e7 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -717,9 +717,82 @@ MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::Parse 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 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 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(dlsym(handle, "CYSetupContext")); diff --git a/Tweak.mm b/Tweak.mm index 6702a7f..cd25dfd 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -43,6 +43,7 @@ #import #import +#import MSClassHook(SpringBoard) MSClassHook(SBAwayController) @@ -56,8 +57,9 @@ MSClassHook(SBAwayView) static bool menu_; static unsigned lock_; +static _H settings_; static _H cydgets_; -static size_t active_ = _not(size_t); +static size_t active_; @interface CydgetController : NSObject { } @@ -69,7 +71,7 @@ static size_t active_ = _not(size_t); @implementation CydgetController + (NSDictionary *) currentConfiguration { - return active_ == _not(size_t) ? nil : [[cydgets_ objectAtIndex:active_] objectForKey:@"Configuration"]; + return [[cydgets_ objectAtIndex:active_] objectForKey:@"Configuration"]; } @end @@ -82,160 +84,90 @@ static size_t active_ = _not(size_t); @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 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 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 159e3be..e100ed2 100644 --- a/control +++ b/control @@ -3,7 +3,7 @@ Priority: optional Section: Development Maintainer: Jay Freeman (saurik) 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) diff --git a/makefile b/makefile index f88b187..2108060 100644 --- 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 + 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 -- 2.45.2