Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
#import <UIKit/UIKit.h> #include <unistd.h> #include <stdlib.h> #include <ctype.h> #import <dlfcn.h> //updates the preferneces after has been changed void (NSString *key) { void *gs = ("/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices", RTLD_LAZY); if(gs != NULL) { int (*updPref)(id appID, id theKey) = (gs, "GSSendAppPreferencesChanged"); (CFSTR("com.apple.springboard"), key); (gs); } } // Determines if the device is capable of running on this platform. If your toggle is device specific like only for BOOL () { return YES; } // This runs when iPhone springboard resets. This is on boot or respring. BOOL () { BOOL Enabled = NO; NSDictionary *plistDict = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.springboard.plist"]; if(plistDict != nil) { int AutoLockT = [[plistDict objectForKey:@"SBAutoLockTime"] intValue]; if (AutoLockT == -1) { Enabled = NO; } else { Enabled = YES; } } return Enabled; } // This function is optional and should only be used if it is likely for the toggle to become out of sync // with the state while the iPhone is running. It must be very fast or you will slow down the animated // showing of the sbsettings window. Imagine 12 slow toggles trying to refresh tate on show. BOOL () { return (); } // Pass in state to set. YES for enable, NO to disable. void (BOOL Enable) { FILE* fp = NULL; int AutoLockT = 0; int AutoDimT = 0; // If we're already in the state being requested, don't do anything. if(() != Enable) { NSMutableDictionary *plistDict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.springboard.plist"]; if(plistDict != nil) { if (Enable == NO) { AutoLockT = [[plistDict objectForKey:@"SBAutoLockTime"] intValue]; AutoDimT = [[plistDict objectForKey:@"SBAutoDimTime"] intValue]; // Store off current autolock values. fp = ("/var/mobile/Library/SBSettings/autolock.sav","wb"); if(fp != NULL) { (&AutoLockT, (AutoLockT), 1, fp); (&AutoDimT, (AutoDimT), 1, fp); (fp); } [plistDict setValue:[NSNumber numberWithInt:-1] forKey:@"SBAutoLockTime"]; [plistDict writeToFile:@"/var/mobile/Library/Preferences/com.apple.springboard.plist" atomically: YES]; [plistDict setValue:[NSNumber numberWithInt:-1] forKey:@"SBAutoDimTime"]; [plistDict writeToFile:@"/var/mobile/Library/Preferences/com.apple.springboard.plist" atomically: YES]; } else if (Enable == YES) { // Store off current autolock values. fp = ("/var/mobile/Library/SBSettings/autolock.sav","rb"); if(fp != NULL) { (&AutoLockT, (AutoLockT), 1, fp); (&AutoDimT, (AutoDimT), 1, fp); (fp); ("/var/mobile/Library/SBSettings/autolock.sav"); } else { AutoDimT = 45; AutoLockT = 60; } [plistDict setValue:[NSNumber numberWithInt:AutoLockT] forKey:@"SBAutoLockTime"]; [plistDict writeToFile:@"/var/mobile/Library/Preferences/com.apple.springbord.plist" atomically: YES]; [plistDict setValue:[NSNumber numberWithInt:AutoDimT] forKey:@"SBAutoDimTime"]; [plistDict writeToFile:@"/var/mobile/Library/Preferences/com.apple.springboard.plist" atomically: YES]; } (@"SBAutoLockTime"); (@"SBAutoDimTime"); } } } // Amount of time spinner should spin in seconds after the toggle is selected. float () { return 0.6f; } // Runs when the dylib is loaded. Only useful for debug. Function can be omitted. __((constructor)) static void () { NSLog(@"Initializing AutoLock Toggle\n"); }