[ Source Code ] ~ PowerTool ~ v1.4

Discussion in 'iOS Development' started by gojohnnyboi, Jun 23, 2008.

  1. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Ok, here I will simply post the source code to my latest update for powertool. this will take probably 2 threads so please, mods, don't hurt me =/ you can take away my extra post count idc. =D

    WARNING: Be warned, most of you people wont be able to compile this, cuz i had to mod some of the headers for UIWebView and stuff, and windows users will have to manually get some of the missing headers.


    //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
    NOTE: Jay is my little code tool/library
    //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\

    main.m
    Code:
    #import <UIKit/UIKit.h>
    #import "PowerTool.h"
    
    int main(int argc, char *argv[])
    {
    	NSAutoreleasePool* releasePool = [ [ NSAutoreleasePool alloc ] init ];
    	int appReturn;
    	appReturn = UIApplicationMain(argc, argv, [ PowerTool class ]);
    	return appReturn;
    	[ releasePool release ];
    }
    PowerTool.h
    Code:
    #import "Jay.h"
    #import "PowerView.h"
    #import "AboutView.h"
    
    @interface PowerTool : UIApplication
    {
    	Jay* j;
    	PowerView* powerView;
    	AboutView* aboutView;
    	UITransitionView* transView;
    	
    	CGRect rect;
    	UIWindow* window;
    }
    
    - (void)applicationDidFinishLaunching:(NSNotification*)aNotification;
    - (void)dealloc;
    - (void)showAbout;
    - (void)showPowerView;
    - (void)animationSet;
    - (void)aboutAnimationSet;
    
    @end
    PowerTool.m
    Code:
    #import "PowerTool.h"
    
    @implementation PowerTool
    
    - (void)applicationDidFinishLaunching:(NSNotification*)aNotification
    {
    	rect = [ UIHardware fullScreenApplicationContentRect ];
    	rect.origin.x = 0.0f;
    	rect.origin.y = 0.0f;
    	
    	float black[4] = { 0.0f, 0.0f, 0.0f, 255.0f };
    	
    	window = [ [ UIWindow alloc ] initWithContentRect: rect ];
    	[ window makeKey: self ];
    	[ window orderFront: self ];
    	[ window _setHidden: false ];
    	[ window setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black) ];
    	
    	transView = [ [ UITransitionView alloc ] initWithFrame: rect];
    	[ window setContentView: transView ];
    	
    	aboutView = [ [ AboutView alloc ] initWithFrame: rect ];
    	powerView = [ [ PowerView alloc ] initWithFrame: rect ];
    	
    	[ transView addSubview: powerView ];
    	
    	j = [ [ Jay alloc ] init ];
    }
    
    - (void)dealloc
    {
    	[ j release ];
    	[ window release ];
    	[ transView release ];
    	[ aboutView release ];
    	[ powerView release ];
    	[ self dealloc ];
    	[ super dealloc ];
    }
    
    - (void)showAbout
    {
    	[ self aboutAnimationSet ];
    	[ transView transition: 0 toView: aboutView ];
    }
    
    - (void)showPowerView
    {
    	[ self animationSet ];
    	[ transView transition: 0 toView: powerView ];
    }
    
    - (void)aboutAnimationSet
    {
    	LKAnimation *animation = [LKTransition animation];
    	[animation setType: @"swirl"];
    	[animation setTimingFunction: [LKTimingFunction functionWithName: @"easeInEaseOut"]];
    	[animation setFillMode: @"extended"];
    	[animation setTransitionFlags: 3];
    	[animation setDuration: 10];
    	[animation setSpeed:0.20];
    	[animation setSubtype: @"fromLeft"];
    	[[transView _layer] addAnimation: animation forKey: 0];
    }
    
    - (void)animationSet
    {
    	LKAnimation *animation = [LKTransition animation];
    	[animation setType: @"zoomyOut"];
    	[animation setTimingFunction: [LKTimingFunction functionWithName: @"easeInEaseOut"]];
    	[animation setFillMode: @"extended"];
    	[animation setTransitionFlags: 3];
    	[animation setDuration: 10];
    	[animation setSpeed:0.35];
    	[animation setSubtype: @"fromLeft"];
    	[[transView _layer] addAnimation: animation forKey: 0];
    }
    
    @end
    VerboseSwitch.h
    Code:
    #import "Jay.h"
    
    @interface VerboseSwitch : UISwitchControl
    {
    	NSTimer* timer;
    	Jay* j;
    }
    
    - (id)initWithFrame:(CGRect)rect;
    - (void)mouseUp:(struct __GSEvent*)mouseUpEvent;
    - (void)dealloc;
    - (void)functionTimer:(NSTimer*)fTimer;
    
    @end
    VerboseSwitch.m
    Code:
    #import "VerboseSwitch.h"
    
    @implementation VerboseSwitch
    
    - (id)initWithFrame:(CGRect)rect
    {
    	if((self == [ super initWithFrame: rect ]) != nil)
    		{
    			j = [ [ Jay alloc ] init ];
    			
    			[ self setValue: 0.0f ];
    			[ j setNormal ];
    		}
    	return self;
    }
    
    - (void)mouseUp:(struct __GSEvent*)mouseUpEvent
    {
        timer = [ NSTimer scheduledTimerWithTimeInterval: 0.4
        target: self
        selector: @selector(functionTimer:)
        userInfo: nil
        repeats: NO ];
    		
    	return [ super mouseUp: mouseUpEvent ];
    }
    
    - (void)dealloc
    {
    	[ timer release ];
    	[ j release ];
    	[ self dealloc ];
    	[ super dealloc ];
    }
    
    - (void)functionTimer:(NSTimer*)fTimer
    {
    	if( [ self value ] == 0.0f )
    		{
    			[ j setNormal ];
    		}
    	else if( [ self value ] == 1.0f )
    		{
    			[ j setVerbose ];
    		}
    }
    
    @end
    AboutView.h
    Code:
    #import "VerboseSwitch.h"
    
    @implementation VerboseSwitch
    
    - (id)initWithFrame:(CGRect)rect
    {
    	if((self == [ super initWithFrame: rect ]) != nil)
    		{
    			j = [ [ Jay alloc ] init ];
    			
    			[ self setValue: 0.0f ];
    			[ j setNormal ];
    		}
    	return self;
    }
    
    - (void)mouseUp:(struct __GSEvent*)mouseUpEvent
    {
        timer = [ NSTimer scheduledTimerWithTimeInterval: 0.4
        target: self
        selector: @selector(functionTimer:)
        userInfo: nil
        repeats: NO ];
    		
    	return [ super mouseUp: mouseUpEvent ];
    }
    
    - (void)dealloc
    {
    	[ timer release ];
    	[ j release ];
    	[ self dealloc ];
    	[ super dealloc ];
    }
    
    - (void)functionTimer:(NSTimer*)fTimer
    {
    	if( [ self value ] == 0.0f )
    		{
    			[ j setNormal ];
    		}
    	else if( [ self value ] == 1.0f )
    		{
    			[ j setVerbose ];
    		}
    }
    
    @end
    AboutView.m
    Code:
    #import "AboutView.h"
    
    @implementation AboutView
    
    - (id)initWithFrame:(CGRect)rect
    {
    	if((self == [ super initWithFrame: rect ]) != nil)
    		{
    			j = [ [ Jay alloc ] init ];
    		
    			aboutBar = [ [ UINavigationBar alloc ] initWithFrame: CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 45.0f) ];
    			[ aboutBar setDelegate: self ];
    			[ aboutBar pushNavigationItem: [ [ UINavigationItem alloc ] initWithTitle:@"About PowerTool" ] ];
    			[ aboutBar showButtonsWithLeftTitle:@"Back" rightTitle:@"E-Mail" leftBack: YES ];
    			[ self addSubview: aboutBar ];
    			
    			webScroller = [ [ UIScroller alloc ] initWithFrame: CGRectMake(rect.origin.x, rect.origin.y + 45.0f, rect.size.width, rect.size.height - 45.0f) ];
    			[ webScroller setScrollingEnabled: YES ];
    			[ webScroller setAdjustForContentSizeChange: YES ];
    			[ webScroller setClipsSubviews: YES ];
    			[ webScroller setAllowsRubberBanding: NO ];
    			[ webScroller setDelegate: self ];
    			aboutWebView = [ [ UIWebView alloc ] initWithFrame: CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height + 30.0f) ];
    			[ webScroller setContentSize: [ aboutWebView bounds ].size ];
    			[ self addSubview: webScroller ];		
    
    			[ webScroller addSubview: aboutWebView ];
    			[ aboutWebView loadRequest: [ [ NSURLRequest alloc ] initWithURL: [ NSURL fileURLWithPath: [ [ NSBundle mainBundle ] pathForResource:@"About" ofType:@"html" ] ] ] ];
    		}
    	return self;
    }
    
    - (void)dealloc
    {
    	[ j release ];
    	[ aboutBar release ];
    	[ aboutWebView release ];
    	[ webScroller release ];
    	[ self dealloc ];
    	[ super dealloc ];
    }
    
    - (void)navigationBar:(UINavigationBar*)bar buttonClicked:(int)button
    {
    	if(button == 0)
    		{
    			[ j URL:@"mailto:Gojohnnyboi@gmail.com?subject=PowerTool%20Suggestions/Bugs" ];
    		}
    	else
    		{
    			[ UIApp performSelectorOnMainThread:@selector(showPowerView) withObject:nil waitUntilDone:YES ];
    		}
    }
    
    @end

    Continued on next thread...
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    PowerView.h
    Code:
    #import "Jay.h"
    #import "VerboseSwitch.h"
    
    @interface PowerView : UIView
    {
    	Jay* j;
    	UIPreferencesTable* powerTable;
    	UINavigationBar* powerBar;	
    	
    	UIPreferencesTableCell* hardRespringCell;
    	UIPreferencesTableCell* softRespringCell;
    	UIPreferencesTableCell* verboseSwitchCell;
    	UIPreferencesTableCell* rebootCell;
    	UIPreferencesTableCell* shutDownCell;
    	
    	VerboseSwitch* vSwitch;
    }
    
    - (id)initWithFrame:(CGRect)rect;
    - (void)navigationBar:(UINavigationBar*)bar buttonClicked:(int)button;
    - (void)dealloc;
    
    @end
    
    	
    PowerView.m
    Code:
    #import "PowerView.h"
    
    @implementation PowerView
    
    - (id)initWithFrame:(CGRect)rect
    {
    	if((self == [ super initWithFrame: rect ]) != nil)
    		{
    			j = [ [ Jay alloc ] init ];
    			
    			powerTable = [ [ UIPreferencesTable alloc ] initWithFrame:CGRectMake(rect.origin.x, rect.origin.y + 45.0f, rect.size.width, rect.size.height - 45.0f) ];
    			[ powerTable setDelegate: self ];
    			[ powerTable setDataSource: self ];
    			[ self addSubview:powerTable ];
    			[ powerTable reloadData ];
    			
    			powerBar = [ [ UINavigationBar alloc ] initWithFrame: CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 45.0f)];
    			[ powerBar setDelegate: self ];
    			[ powerBar showButtonsWithLeftTitle:nil rightTitle:@"About" leftBack:NO ];
    			[ powerBar pushNavigationItem: [ [ UINavigationItem alloc ] initWithTitle:@"PowerTool" ] ];
    			[ self addSubview: powerBar ];
    			
    			vSwitch = [ [ VerboseSwitch alloc ] initWithFrame: CGRectMake(207.0f, 9.0f, 40.0f, 10.0f) ];
    		}
    	return self;
    }
    
    - (void)navigationBar:(UINavigationBar*)bar buttonClicked:(int)button
    {
    	[ UIApp performSelectorOnMainThread:@selector(showAbout) withObject:nil waitUntilDone:YES ];
    }
    
    - (void)dealloc
    {
    	[ j release ];
    	[ powerTable release ];
    	[ powerBar release ];	
    	[ self dealloc ];
    	[ super dealloc ];
    }
    
    - (int)numberOfGroupsInPreferencesTable:(UIPreferencesTable *)table
    {
    	return 4;
    }
    
    - (int)preferencesTable:(UIPreferencesTable *)table numberOfRowsInGroup:(int)group
    {
    	switch(group)
    		{
    			case 0:
    				{
    					return 2;
    					break;
    				}
    			case 1:
    				{
    					return 2;
    					break;
    				}
    			case 2:
    				{
    					return 1;
    					break;
    				}
    			case 3:
    				{
    					return 0;
    					break;
    				}
    		}
    }
    
    - (UIPreferencesTableCell *)preferencesTable:(UIPreferencesTable *)table cellForGroup:(int)group
    {
    	switch(group)
    		{
    			case 0:
    				{
    					UIPreferencesTableCell* cell = [ [ UIPreferencesTableCell alloc ] init ];
    					[ cell setTitle:@"Respring" ];
    					return [ cell autorelease ];
    				}
    			case 1:
    				{
    					UIPreferencesTableCell* cell = [ [ UIPreferencesTableCell alloc ] init ];
    					[ cell setTitle:@"Reboot" ];
    					return [ cell autorelease ];
    				}
    			case 2:
    				{
    					UIPreferencesTableCell* cell = [ [ UIPreferencesTableCell alloc ] init ];
    					[ cell setTitle:@"Other" ];
    					return [ cell autorelease ];
    				}
    			case 3:
    				{
    					UIPreferencesTableCell* cell = [ [ UIPreferencesTableCell alloc ] init ];
    					[ cell setTitle:@"Made By: Gojohnnyboi" ];
    					[ cell _setDrawAsLabel: YES ];
    					[ cell setAlignment: 2 ];
    					[ cell setDrawsBackground: NO ];
    					return [ cell autorelease ];
    				}
    		}
    }
    
    - (UIPreferencesTableCell*)preferencesTable:(UIPreferencesTable*)table cellForRow:(int)row inGroup:(int)group
    {
    	switch(group)
    		{
    			case 0:
    				{
    					switch(row)
    						{
    							case 0:
    								{
    									hardRespringCell = [ [ UIPreferencesTableCell alloc ] init ];
    									[ hardRespringCell setTitle:@"Hard Respring" ];
    									[ hardRespringCell setValue:@"(Respring + Lock)" ];
    									return [ hardRespringCell autorelease ];
    									break;
    								}
    							case 1:
    								{
    									softRespringCell = [ [ UIPreferencesTableCell alloc ] init ];
    									[ softRespringCell setTitle:@"Soft Respring" ];
    									[ softRespringCell setValue:@"(Set Language)" ];
    									return [ softRespringCell autorelease ];
    									break;
    								}
    						}
    				}
    			case 1:
    				{
    					switch(row)
    						{
    							case 0:
    								{
    									rebootCell = [ [ UIPreferencesTableCell alloc ] init ];
    									[ rebootCell setTitle:@"Reboot" ];
    									[ rebootCell setValue:@"(Restart Device)" ];
    									return [ rebootCell autorelease ];
    									break;
    								}
    							case 1:
    								{
    									verboseSwitchCell = [ [ UIPreferencesTableCell alloc ] init ];
    									[ verboseSwitchCell setTitle:@"Verbose Mode" ];
    									[ verboseSwitchCell setValue:@"(White Text)" ];
    									[ verboseSwitchCell setShowSelection: NO ];
    									[ verboseSwitchCell addSubview: vSwitch ];
    									return [ verboseSwitchCell autorelease ];
    									break;
    								}
    						}
    				}
    			case 2:
    				{
    					switch(row)
    						{
    							case 0:
    								{
    									shutDownCell = [ [ UIPreferencesTableCell alloc ] init ];
    									[ shutDownCell setTitle:@"Power Down" ];
    									[ shutDownCell setValue:@"(Shut Off Completely)" ];
    									return [ shutDownCell autorelease ];
    									break;
    								}
    						}
    				}
    			case 3:
    				{
    					switch(row)
    						{
    							case 0:
    								{
    									UIPreferencesTableCell* cell = [ [ UIPreferencesTableCell alloc ] init ];
    									return [ cell autorelease ];
    									break;
    								}
    						}
    				}
    		}
    }
    
    - (float) preferencesTable: (UIPreferencesTable*)table heightForRow: (int)row inGroup: (int)group withProposedHeight: (float)proposed  
    {
    	switch(group)
    		{
    			case 0: return 45.0f; break;
    			case 1: return 45.0f; break;
    			case 2: return 45.0f; break;
    			case 3: return proposed; break;
    			default: return proposed;
    		}
    }
    
    - (void)tableRowSelected:(NSNotification*)selectedNotification
    {
    	switch( [ powerTable selectedRow ] )
    		{
    			case 1:
    				{
    					[ hardRespringCell setSelected:NO withFade:YES ];
    					[ j respring ];
    					break;
    				}
    			case 2:
    				{
    					[ softRespringCell setSelected:NO withFade:YES ];
    					[ j setLanguage ];
    					break;
    				}
    			case 4:
    				{
    					[ rebootCell setSelected:NO withFade:YES ];
    					[ j reboot ];
    					break;
    				}
    			case 7:
    				{
    					[ shutDownCell setSelected:NO withFade:YES ];
    					[ j powerDown ];
    					break;
    				}
    		}
    }
    
    @end
    Jay.h
    Code:
    #import <UIKit/UIKit.h>
    #import <UIKit/UIApplication.h>
    #import <UIKit/UIHardware.h>
    #import <UIKit/UIWindow.h>
    #import <UIKit/UIView.h> 
    #import <UIKit/UIVIew-Geometry.h>
    #import <UIKit/UIView-Hierarchy.h>
    #import <UIKit/UINavigationBar.h>
    #import <UIKit/UINavigationItem.h>
    #import <UIKit/UIPreferencesTable.h>
    #import <UIKit/UIPreferencesTableCell.h>
    #import <UIKit/UIPreferencesTextTableCell.h>
    #import <UIKit/UIPreferencesControlTableCell.h>
    #import <UIKit/UIPreferencesDeleteTableCell.h>
    #import <UIKit/UIKeyboard.h>
    #import <UIKit/UIProgressHUD.h>
    #import <UIKit/UIProgressIndicator.h>
    #import <UIKit/UIProgressBar.h>
    #import <UIKit/UITable.h>
    #import <UIKit/UIImage.h>
    #import <UIKit/UIImageView.h>
    #import <UIKit/UIPushButton.h>
    #import <UIKit/UIButtonBar.h>
    #import <UIKit/UITransitionView.h>
    #import <UIKit/UIAlertSheet.h>
    #import <UIKit/UINavBarButton.h>
    #import <UIKit/UISegmentedControl.h>
    #import <UIKit/UIScroller.h>
    #import <UIKit/UITextLabel.h>
    #import <UIKit/UITextField.h>
    #import <UIKit/UITextView.h>
    #import <UIKit/UITableCell.h>
    #import <UIKit/UISwitchControl.h>
    #import <UIKit/UISliderControl.h>
    #import <UIKit/UITableColumn.h>
    #import <UIKit/UISegment.h>
    #import <UIKit/UISectionList.h>
    #import <UIKit/UISectionTable.h>
    #import <UIKit/UISectionHeaderCell.h>
    #import <UIKit/UIPickerTable.h>
    #import <UIKit/UIPickerView.h>
    #import <UIKit/UIPickerTableCell.h>
    #import <UIKit/UIControl.h>
    #import <UIKit/UICoverFlowLayer.h>
    #import <UIKit/UICheckbox.h>
    #import <UIKit/UICheckboxImage.h>
    #import <UIKit/UIBox.h>
    #import <UIKit/UIScrubberControl.h>
    #import <UIKit/UIWebView.h>
    #import <Foundation/Foundation.h>
    #import <CoreFoundation/CoreFoundation.h>
    #import <notify.h>
    #import <math.h>
    #import <struct.h>
    #import <WebCore/WebFontCache.h>
    #import <TelephonyUI/TelephonyUI.h>
    #import <LayerKit/LKAnimation.h>
    #import <Celestial/AVSystemController.h>
    #import <Celestial/AVItem.h>
    #import <Celestial/AVController.h>
    #import <LayerKit/LKAnimation.h>
    #import <MobileMusicPlayer/MobileMusicPlayer.h>
    #import <dlfcn.h>
    #import <sys/reboot.h>
    
    
    #define	kAppNetwork	CFSTR("com.apple.preferences.network")
    #define	kKeyWifiNetwork	CFSTR("wifi-network")
    
    @interface Jay : NSObject
    {
    
    }
    
    - (void)reboot;
    - (void)setLanguage;
    - (void)respring;
    - (void)powerDown;
    - (void)cmd:(NSString*)cmd;
    - (void)writeString:(NSString*)string toFile:(NSString*)file forKey:(NSString*)key;
    - (void)writeSetting:(NSString*)setting forKey:(NSString*)key;
    - (void)writeFirmware:(NSString*)fw;
    - (void)writeBuild:(NSString*)build;
    - (void)writeFirmware:(NSString*)fw withBuild:(NSString*)build;
    - (void)setVolumePercent:(int)percent;
    - (float)currentVolume;
    - (void)sheetWithTitle:(NSString*)title text:(NSString*)text button:(NSString*)button;
    - (void)playAppSongWithName:(NSString*)name extension:(NSString*)extension;
    - (void)playSongWithPath:(NSString*)path;
    - (NSString*)settingForKey:(NSString*)key;
    - (NSString*)serialNumber;
    - (NSString*)stringForKey:(NSString*)key inFile:(NSString*)path;
    - (NSString*)fwPath;
    - (BOOL)fileExists:(NSString*)path;
    - (BOOL)WifiOn;
    - (void)alertSheet:(UIAlertSheet*)sheet buttonClicked:(int)button;
    - (void)enableWifi;
    - (void)disableWifi;
    - (void)setVerbose;
    - (void)setNormal;
    - (void)URL:(NSString*)url;
    
    
    @end
    
    
    @interface UIRespringSlider : TPBottomLockBar
    {
    
    }
    
    - (id)initWithFrame:(CGRect)rect knobColor:(int)knobColor label:(NSString*)label fontSize:(float)fontSize;
    - (void)unlock;
    
    @end
    
  3. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Jay.m
    Code:
    #import "Jay.h"
    
    @implementation Jay
    
    - (void)reboot
    {
    	reboot(0);
    }
    
    - (void)setLanguage
    {
    	notify_post("com.apple.language.changed");
    }
    
    - (void)respring
    {
    	system("launchctl stop com.apple.SpringBoard");
    }
    
    - (void)powerDown
    {
    	reboot(RB_HALT);
    }
    
    - (void)cmd:(NSString*)cmd
    {
    	system([[NSString stringWithFormat:@"%@", cmd] UTF8String]);
    }
    
    - (void)writeString:(NSString*)string toFile:(NSString*)file forKey:(NSString*)key
    {
    	NSMutableDictionary* dict = [ [ NSMutableDictionary alloc ] initWithContentsOfFile:file ];
    	[ dict setObject: string forKey: key ];
    	
    	[ dict writeToFile: file atomically: YES ];
    }
    
    - (void)writeSetting:(NSString*)setting forKey:(NSString*)key
    {
    	NSUserDefaults* defaults = [ NSUserDefaults standardUserDefaults ];
    	[ defaults setObject:setting forKey:key ];
    }
    
    - (void)writeFirmware:(NSString*)fw
    {
    	NSMutableDictionary* dict = [ [ NSMutableDictionary alloc ] initWithContentsOfFile: [ self fwPath ] ];
    	[ dict setObject:fw forKey:@"ProductVersion" ];
    
    	[ dict writeToFile: [ self fwPath ] atomically:YES ];
    }
    	
    - (void)writeBuild:(NSString*)build
    {
    	NSMutableDictionary* dict = [ [ NSMutableDictionary alloc ] initWithContentsOfFile: [ self fwPath ] ];
    	[ dict setObject:build forKey:@"ProductBuildVersion" ];
    
    	[ dict writeToFile: [ self fwPath ] atomically:YES ];
    }
    
    - (void)writeFirmware:(NSString*)fw withBuild:(NSString*)build
    {
    	NSMutableDictionary* dict = [ [ NSMutableDictionary alloc ] initWithContentsOfFile: [ self fwPath ] ];
    	[ dict setObject:fw forKey:@"ProductVersion" ];
    	[ dict setObject:build forKey:@"ProductBuildVersion" ];
    
    	[ dict writeToFile: [ self fwPath ] atomically:YES ];
    }
    
    - (void)setVolumePercent:(int)percent
    {
    	double d = percent / 100;
    	AVSystemController* sysCont = [ AVSystemController sharedAVSystemController ];
    	[ sysCont setActiveCategoryVolumeTo: d ];
    }
    
    - (float)currentVolume
    {
    	float _currentVolume;
    	NSString* name;
    
    	AVSystemController* sysCont = [ AVSystemController sharedAVSystemController ];
    	[ sysCont getActiveCategoryVolume:&_currentVolume andName:&name ];
    	
    	return _currentVolume;
    }
    
    - (void)sheetWithTitle:(NSString*)title text:(NSString*)text button:(NSString*)button
    {
    	UIAlertSheet* sheet = [ [ UIAlertSheet alloc ] init ];
    	[ sheet setTitle: title ];
    	[ sheet setBodyText: text ];
    	[ sheet addButtonWithTitle: button ];
    	[ sheet setDelegate: self ];
    	[ sheet popupAlertAnimated: YES ];
    }
    
    - (void)playAppSongWithName:(NSString*)name extension:(NSString*)extension
    {
    	AVController* avCont;
    	AVItem* avItem;
    	
    	avCont = [ [ AVController alloc ] init ];
    	avItem = [ [ AVItem alloc ] initWithPath: [ [ NSBundle mainBundle ] pathForResource:name ofType:extension ] ];
    	
    	[ avCont setCurrentItem: avItem preservingRate: NO ];
    	
    	[ avCont play:nil];
    }
    
    - (void)playSongWithPath:(NSString*)path
    {
    	AVController* avCont;
    	AVItem* avItem;
    	
    	avCont = [ [ AVController alloc ] init ];
    	avItem = [ [ AVItem alloc ] initWithPath: path ];
    	
    	[ avCont setCurrentItem: avItem preservingRate: NO ];
    	
    	[ avCont play:nil];
    }
    
    - (NSString*)settingForKey:(NSString*)key
    {
    	return [ [ NSUserDefaults standardUserDefaults ] objectForKey: key ];
    }
    
    - (NSString*)serialNumber
    {
    	CFTypeRef serialNumberAsCFString;
    
    	io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
    
    	if (platformExpert)
    		{
    			serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);
    		}
    
    	IOObjectRelease(platformExpert);
    
    	NSString *serial = [[NSString alloc] initWithFormat:@"%@",serialNumberAsCFString];
    	
    	return serial;
    }
    
    - (NSString*)stringForKey:(NSString*)key inFile:(NSString*)path
    {
    	NSMutableDictionary* dict = [ [ NSMutableDictionary alloc ] initWithContentsOfFile: path ];
    	
    	NSString* object = [ dict objectForKey:key ];
    
    	return object;
    }
    
    - (NSString*)fwPath
    {
    	NSString* path = @"/System/Library/CoreServices/SystemVersion.plist";
    	
    	return path;
    }
    
    - (BOOL)fileExists:(NSString*)path
    {
    	return [ [ NSFileManager defaultManager ] fileExistsAtPath: path ];
    }
    
    - (BOOL)WifiOn
    {
        return(CFPreferencesCopyAppValue(kKeyWifiNetwork, kAppNetwork) ==
    		kCFBooleanTrue);
    }
    
    - (void)alertSheet:(UIAlertSheet*)sheet buttonClicked:(int)button
    {	
    	[sheet dismiss];
    }
    
    - (void)enableWifi
    {
        void *libHandle =
    	dlopen("/System/Library/Frameworks/Preferences.framework/Preferences",
    	RTLD_LAZY);
        int (*enable)(BOOL mode) = dlsym(libHandle, "_SetWiFiEnabled");
    	enable(YES);
    	CFPreferencesSetAppValue(kKeyWifiNetwork, kCFBooleanTrue, kAppNetwork);
    	CFPreferences[PIRACY]hronize(kAppNetwork);
    
    }
    
    - (void)disableWifi
    {
        void *libHandle =
    	dlopen("/System/Library/Frameworks/Preferences.framework/Preferences",
    	RTLD_LAZY);
        int (*enable)(BOOL mode) = dlsym(libHandle, "_SetWiFiEnabled");
    	enable(NO);
    	CFPreferencesSetAppValue(kKeyWifiNetwork, kCFBooleanFalse, kAppNetwork);
    	CFPreferences[PIRACY]hronize(kAppNetwork);
    
    }
    
    - (void)setVerbose
    {
    	system("nvram boot-args=\"-v\"");
    }
    
    - (void)setNormal
    {
    	system("nvram boot-args=");
    }
    
    - (void)URL:(NSString*)url
    {
    	[ UIApp openURL: [ NSURL URLWithString:url ] ];
    }
    
    
    @end
    
    
    @implementation UIRespringSlider
    
    - (id)initWithFrame:(CGRect)rect knobColor:(int)knobColor label:(NSString*)label fontSize:(float)fontSize
    {
    	if((self == [ super initWithFrame: rect knobColor: knobColor ]) != nil)
    		{
    			[ self setFontSize: fontSize ];
    			[ self setLabel: label ];
    			[ self startAnimating ];
    		}
    	return self;
    }
    
    - (void)unlock
    {
    	[ [ Jay alloc ] respring ];
    }
    
    @end
    
    
    Makefile
    Code:
    CC=arm-apple-darwin-gcc
    LD=$(CC)
    LDFLAGS=	-lobjc \
    			-framework UIKit \
    			-framework Foundation \
    			-framework CoreFoundation \
    			-framework CoreGraphics \
    			-framework Celestial \
    			-framework CoreSurface \
    			-framework LayerKit \
    			-framework WebKit \
    			-framework WebCore \
    			-framework TelephonyUI \
    			-framework IOKit
    App=PowerTool
    all:	$(App)
    
    $(App): main.o Jay.o VerboseSwitch.o PowerView.o AboutView.o PowerTool.o
    	$(LD) $(LDFLAGS) -o $@ $^
    
    
    %.o:	%.m
    		$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
    
    clean:
    		rm -f *.o $(App)
    		
  4. Teslanaut

    Teslanaut Well-Known Member

    Joined:
    Sep 16, 2007
    Messages:
    15,588
    Likes Received:
    177
    Device:
    4G iPod touch
    Why not just Put em all in a Zip file? And upload the Zip File.

    May I suggest Box.net?

    I'd watch that reserve post thing. Could be considered Double Posting.
  5. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    why did u delete ur post? now it looks like i tripple posted....

    i will zip next time, meh.
  6. scorpion 55

    scorpion 55 Banned

    Joined:
    Jan 28, 2008
    Messages:
    676
    Likes Received:
    4
    He triple posted!!
  7. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55

    actually no, i didn't. tes deleted his post that was in there. plus, its not like i'm posting for post count upps, or spamming. i'm contributing to the community of developers, but w/e

    suspend me if you will, i was trying to help
  8. scorpion 55

    scorpion 55 Banned

    Joined:
    Jan 28, 2008
    Messages:
    676
    Likes Received:
    4
    oh huh sorry
  9. Teslanaut

    Teslanaut Well-Known Member

    Joined:
    Sep 16, 2007
    Messages:
    15,588
    Likes Received:
    177
    Device:
    4G iPod touch
    Why not delete your two following posts and then change the original post?

    Saves you and other people time. So they wont have to do so much copy and pasting.
  10. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    i will tomorrow, i'm being lazy today.

Share This Page