All pastes #817070 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-15 05:37 UTC
rendered paste body


#import <UIKit/UIKit.h>
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/CDStructures.h>
#import <UIKit/UINavigationBar.h>
#import <UIKit/UIPreferencesTable.h>
#import <UIKit/UIPreferencesControlTableCell.h>
#import <UIKit/UIPreferencesTextTableCell.h>
#import <UIKit/UIWindow.h>
#import <UIKit/UIHardware.h>
#import <UIKit/UIControl.h>
#import <UIKit/UIImageView.h>   


#import "PSSpecifiers.h"
#import "ServiceTableCell.h"
#import "SSHServiceTableCell.h"
#import "WifiServiceTableCell.h"
#import "FireflyServiceTableCell.h"
#import "ApacheServiceTableCell.h"
#import "EDGEServiceTableCell.h"
#import "AFPServiceTableCell.h"
#import "PhoneServiceTableCell.h"
#import "BluetoothServiceTableCell.h"
#import "SocksServiceTableCell.h"
#import "TinyproxyServiceTableCell.h"
#import "SambaServiceTableCell.h"
#import "LighttpdServiceTableCell.h"
#import "IPTableCell.h"
#import "AutolockServiceTableCell.h"
#import "FileShareServiceTableCell.h"
#import "iSpitServiceTableCell.h"
#import "ASnapServiceTableCell.h"
#import "ServiceTableCell2.h"
#import "SSHServiceTableCell2.h"
#import "WifiServiceTableCell2.h"
#import "FireflyServiceTableCell2.h"
#import "ApacheServiceTableCell2.h"
#import "EDGEServiceTableCell2.h"
#import "AFPServiceTableCell2.h"
#import "PhoneServiceTableCell2.h"
#import "BluetoothServiceTableCell2.h"
#import "SocksServiceTableCell2.h"
#import "TinyproxyServiceTableCell2.h"
#import "SambaServiceTableCell2.h"
#import "LighttpdServiceTableCell2.h"
#import "IPTableCell2.h"
#import "AutolockServiceTableCell2.h"
#import "FileShareServiceTableCell2.h"
#import "iSpitServiceTableCell2.h"
#import "ASnapServiceTableCell2.h"


#import "ButtonBarView.h"

/*
 * Main
 */
int main(int argc, char **argv)
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	
    int a = UIApplicationMain(argc, argv, [ App class]);
    [pool release];
	
    return a;
}

/*
 * App
 */
@implementation App

- (void) applicationDidFinishLaunching: (id) fp8 {
	
	// init main window for the application to be the whole screen.
	struct CGRect frame = [UIHardware fullScreenApplicationContentRect];
	frame.origin.x = frame.origin.y = 0.0f;
	mainWindow = [[UIWindow alloc] initWithContentRect: frame];
	
	// The "master" view that contains other views
	//masterView = [[MasterView alloc] initWithFrame: frame];
	buttonBarView = [[ButtonBarView alloc] initWithFrame:CGRectMake(0,0,320,460)];
	
	
	[super setStatusBarMode:3 duration:0]; 
	[mainWindow orderFront: self];
	[mainWindow makeKey: self];
	[mainWindow _setHidden: NO];	
	[mainWindow setContentView: /*masterView*/ buttonBarView]; 
	[buttonBarView release];
}

@end



/*
 * ButtonBarView
 */
@implementation ButtonBarView

-(id)initWithFrame:(CGRect)frame
{
	if ((self == [super initWithFrame:frame])!=nil) {
		
		barStatus = 1;
		
		rect = [UIHardware fullScreenApplicationContentRect];
		_offScreenRect = frame;
		_onScreenRect = frame;
		_onScreenRect.origin.x = 0.0f;
		rect.origin.x = rect.origin.y = 0.0f;
		
		// Create some colors
		float black[4] = {0, 0, 0, 1};
		
		
		
		// Create your views
		testview1 = [ [ UIView alloc ] initWithFrame:CGRectMake(0,0,320,460)];
		testview2 = [ [ UIView alloc ] initWithFrame:CGRectMake(0,0,320,460)];
		testview3 = [ [ UIView alloc ] initWithFrame:CGRectMake(0,0,320,460)];
		testview4 = [ [ UIView alloc ] initWithFrame:CGRectMake(0,0,320,460)];
		testview5 = [ [ UIView alloc ] initWithFrame:CGRectMake(0,0,320,460)];
		[testview1 setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
		[testview2 setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
		[testview3 setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
		[testview4 setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
		[testview5 setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
		
		
		
		//--------------------------------------------------Table set up------------------------------------------------------------------	
		
		// Services Page
		NSLog(@"Starting");
		/* Create the Preferences Table, it holds all the controls on the preferences page */
		pref = [[UIPreferencesTable alloc] initWithFrame: CGRectMake(0.0f, 36.0f, 320.0f, 480.0f-40.0f)];
		
		/* Tell the preferences table to get its data from this class */
		[pref setDataSource: self];
		
		/* Tell the preferences table to send events to this class */
		[pref setDelegate: self];
		[pref setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
		
		/* Create the 2nd Preferences Table, it holds all the controls on the preferences page */
		pref2 = [[UIPreferencesTable alloc] initWithFrame: CGRectMake(0.0f, 36.0f, 320.0f, 480.0f-40.0f)];
		
		/* Tell the preferences table to get its data from this class */
		[pref2 setDataSource: self];
		
		/* Tell the preferences table to send events to this class */
		[pref2 setDelegate: self];
		[pref2 setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
		
		//--------------------------------------------------------------------------------------------------------------------	

		/* Necessary variables for setting up preferences table */
		CGRect controlPos = CGRectMake(0.0f, 0.0f, 320.0f, 45.0f);
		
		
		NSFileManager *fileManager = [NSFileManager defaultManager];
		NSDictionary *oneViewDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/Applications/NetServices.app/ProgramFiles/plists/settings.plist"];
				
			/* Create header cell for IP Address*/
		NSString *ipVisibility = [oneViewDictionary objectForKey:@"Visibility-IP"];
		if ([ipVisibility isEqualToString:@"YES"]) {
			netServicesHeader  = [[IPTableCell alloc] init];
			[netServicesHeader _setDrawAsLabel: NO];
			[netServicesHeader setDrawsBackground: YES];
			[netServicesHeader setIcon: [[UIImage imageAtPath:[[NSBundle mainBundle] pathForResource:@"ip" ofType:@"png" inDirectory:@"/ProgramFiles/icons"]] autorelease]];
		} else if ([ipVisibility isEqualToString:@"YES"] == NO) {
			netServicesHeader  = [[UIPreferencesTableCell alloc] init];
			[netServicesHeader _setDrawAsLabel: NO];
			[netServicesHeader setDrawsBackground: NO];
			[netServicesHeader setTitle:@"  "];
		}
	
		
		//---------------------------ServicesArray-----------------------------------------------
		
		/* Holds the services that are listed under the Network Services group */    
		servicesArray = [[[NSMutableArray alloc] init] retain];
		
		NSString *edgeVisibility = [oneViewDictionary objectForKey:@"Visibility-EDGE"];
		if ([edgeVisibility isEqualToString:@"YES"]) {
			/* Initialize the Edge Service Control */
			EDGE = [[EDGEServiceTableCell alloc] initWithFrame: controlPos];
			[EDGE setDelegate:self];
			
			/* Add this to the array of services */
			[servicesArray addObject:EDGE];
		}
		
		NSString *bluetoothVisibility = [oneViewDictionary objectForKey:@"Visibility-Bluetooth"];
		if ([bluetoothVisibility isEqualToString:@"YES"]) {
			/* Initialize the Bluetooth Control */
			Bluetooth = [[BluetoothServiceTableCell alloc] initWithFrame: controlPos];
			[Bluetooth setDelegate:self];
			
			/* Add this to the array of services */
			[servicesArray addObject:Bluetooth];
		}
		
		
		NSString *wifiVisibility = [oneViewDictionary objectForKey:@"Visibility-Wifi"];
		if ([wifiVisibility isEqualToString:@"YES"]) {
			/* Initialize the Wifi Control */
			Wifi = [[WifiServiceTableCell alloc] initWithFrame: controlPos];
			
			/* Add this to the array of services */
			[servicesArray addObject:Wifi];
		}
		
		
		NSString *phoneVisibility = [oneViewDictionary objectForKey:@"Visibility-Airplane"];
		if ([phoneVisibility isEqualToString:@"YES"]) {
			/*Initialize the Phone Service Control*/
			Airplane = [[PhoneServiceTableCell alloc] initWithFrame: controlPos];
			
			/*Add this to the array of services*/
			[servicesArray addObject:Airplane];
		}
		
		
		
		NSString *sshVisibility =  [oneViewDictionary objectForKey:@"Visibility-SSH"];
		if ([sshVisibility isEqualToString:@"YES"]) {
			/* Initialize the OpenSSH Control */    
			/* Add this to the array of services, only if the opensshd daemon exists */
			if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.openssh.sshd.plist"]) {
				SSH = [[SSHServiceTableCell alloc] initWithFrame: controlPos andSSHplist:@"/Library/LaunchDaemons/com.openssh.sshd.plist"];
				[servicesArray addObject:SSH];
			}
		}
		
		
		
		NSString *dropbearVisibility  = [oneViewDictionary objectForKey:@"Visibility-Dropbear"];
		if ([dropbearVisibility isEqualToString:@"YES"]) {    
			/* Initialize the Dropbear SSH Control */
			Dropbear = nil;
			NSString *dropbear = @"/System/Library/LaunchDaemons/au.asn.ucc.matt.dropbear.plist";
			if ([fileManager fileExistsAtPath:dropbear]) {
				Dropbear = [[SSHServiceTableCell alloc] initWithFrame: controlPos andSSHplist:dropbear];
			} else if ([fileManager fileExistsAtPath:(dropbear = @"/Library/LaunchDaemons/au.asn.ucc.matt.dropbear.plist")]) {
				Dropbear = [[SSHServiceTableCell alloc] initWithFrame: controlPos andSSHplist:dropbear];
			}
			
			/* Add this to the array of services, only if the sshd daemon exists */
			if (Dropbear != nil) {
				[servicesArray addObject:Dropbear];
			}
		}
		
		NSString *afpVisibility = [oneViewDictionary objectForKey:@"Visibility-AFP"];
		if ([afpVisibility isEqualToString:@"YES"]) {
			/* Initialize the AFP Control */    
			/* Add this to the array of services, only if the AFP daemon exists */
			if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.core.afp.plist"]) {
				AFP = [[AFPServiceTableCell alloc] initWithFrame: controlPos andAFPplist:@"/Library/LaunchDaemons/com.core.afp.plist"];
				[servicesArray addObject:AFP];
			}
		}
		
		NSString *sambaVisibility = [oneViewDictionary objectForKey:@"Visibility-Samba"];
		if ([sambaVisibility isEqualToString:@"YES"]) {
			/* Initialize the Samba Control */    
			/* Add this to the array of services, only if the Samba daemon exists */
			if ([fileManager fileExistsAtPath:@"/usr/local/samba/smbd"]) {
				Samba = [[SambaServiceTableCell alloc] initWithFrame: controlPos andSAMplist:@"smbd -D.plist"];
				[servicesArray addObject:Samba];
			}
		}
		
		NSString *fireflyVisibility = [oneViewDictionary objectForKey:@"Visibility-Firefly"];
		if ([fireflyVisibility isEqualToString:@"YES"]) {
			/* Initialize the FireFly Control */    
			/* Add this to the array of services, only if the Firefly daemon exists */
			if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/org.fireflymediaserver.mt-daapd.plist"]) {
				Firefly = [[FireflyServiceTableCell alloc] initWithFrame: controlPos andFFplist:@"/Library/LaunchDaemons/org.fireflymediaserver.mt-daapd.plist"];
				[servicesArray addObject:Firefly];
			}
		}
		
		NSString *apacheVisibility = [oneViewDictionary objectForKey:@"Visibility-Apache"];
		if ([apacheVisibility isEqualToString:@"YES"]) {
			/* Initialize the Apache Control */    
			/* Add this to the array of services, only if the Apache daemon exists */
			if ([fileManager fileExistsAtPath:@"/System/Library/LaunchDaemons/org.apache.httpd.plist"]) {
				Apache = [[ApacheServiceTableCell alloc] initWithFrame: controlPos andAPplist:@"/System/Library/LaunchDaemons/org.apache.httpd.plist"];
				[servicesArray addObject:Apache];
			}
		}
		
		NSString *iSpitVisibility = [oneViewDictionary objectForKey:@"Visibility-iSpit"];
		if ([iSpitVisibility isEqualToString:@"YES"]) {
			/* Initialize the Apache Control */    
			/* Add this to the array of services, only if the iSpit daemon exists */
			if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/nl.robota.iphone.ispit.plist"]) {
				iSpit = [[iSpitServiceTableCell alloc] initWithFrame: controlPos andSPIplist:@"/Library/LaunchDaemons/nl.robota.iphone.ispit.plist"];
				[servicesArray addObject:iSpit];
			}
		}
		
		
		NSString *lighttpdVisibility = [oneViewDictionary objectForKey:@"Visibility-Lighttpd"];
		if ([lighttpdVisibility isEqualToString:@"YES"]) {
			/* Initialize the Lighttpd Control */    
			/* Add this to the array of services, only if the Lighttpd daemon exists */
			if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.amcgregor.lighttpd.plist"]) {
				Lighttpd = [[LighttpdServiceTableCell alloc] initWithFrame: controlPos andLTPDplist:@"/Library/LaunchDaemons/com.amcgregor.lighttpd.plist"];
				[servicesArray addObject:Lighttpd];
			}
		}
		
		
		NSString *fileshareVisibility = [oneViewDictionary objectForKey:@"Visibility-Fileshare"];
		if ([fileshareVisibility isEqualToString:@"YES"]) {
			/* Initialize the Filemanger Control */    
			/* Add this to the array of services, only if the AFP daemon exists */
			if ([fileManager fileExistsAtPath:@"/System/Library/Internet Plug-Ins/File Download Plugin.webplugin/Info.plist"]) {
				Fileshare = [[FileShareServiceTableCell alloc] initWithFrame: controlPos andFSplist:@"test.plist"];
				[servicesArray addObject:Fileshare];
			}
		}
		
		NSString *autosnapVisibility = [oneViewDictionary objectForKey:@"Visibility-Autosnap"];
		if ([autosnapVisibility isEqualToString:@"YES"]) {
			/* Initialize the autosnap Control */    
			/* Add this to the array of services, only if the Asnap daemon exists */
			if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.sadun.autosnap"]) {
				Autosnap = [[ASnapServiceTableCell alloc] initWithFrame: controlPos andASNplist:@"/var/root/bin/autosnap.plist"];
				[servicesArray addObject:Autosnap];
			}
		}
		
		NSString *socksVisibility = [oneViewDictionary objectForKey:@"Visibility-Socks"];
		if ([socksVisibility isEqualToString:@"YES"]) {
			/* Initialize the Socks Server Control */    
			/* Add this to the array of services, only if the Socks Server daemon exists */
			if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/net.sourceforge.socks-relay.srelay.plist"]) {
				Socks = [[SocksServiceTableCell alloc] initWithFrame: controlPos andSOCKSplist:@"/Library/LaunchDaemons/net.sourceforge.socks-relay.srelay.plist"];
				[servicesArray addObject:Socks];
			}
		}
		
		NSString *tinyproxyVisibility = [oneViewDictionary objectForKey:@"Visibility-Tinyproxy"];
		if ([tinyproxyVisibility isEqualToString:@"YES"]) {		
			/* Initialize the Tinyproxy  Control */    
			/* Add this to the array of services, only if the Tinyproxy daemon exists */
			Tinyproxy = nil;
			NSString *tinyproxy = @"/System/Library/LaunchDaemons/com.wickedpsyched.iphone.tinyproxy.plist";
			if ([fileManager fileExistsAtPath:tinyproxy]) {
				Tinyproxy = [[TinyproxyServiceTableCell alloc] initWithFrame: controlPos andTNPplist:tinyproxy];
			} else if ([fileManager fileExistsAtPath:@"/System/Library/LaunchDaemonscom.wickedpsyched.iphone.tinyproxy.plist"]) {
				Tinyproxy = [[TinyproxyServiceTableCell alloc] initWithFrame: controlPos andTNPplist:@"/System/Library/LaunchDaemons/com.wickedpsyched.iphone.tinyproxy.plist"];
			}
			if (Tinyproxy != nil) {
				[servicesArray addObject:Tinyproxy];
			}
		}
		
		NSString *autolockVisibility = [oneViewDictionary objectForKey:@"Visibility-Autolock"];
		if ([autolockVisibility isEqualToString:@"YES"]) {
			/* Initialize the Autolock Control  Add this to the array of services */
			Autolock = [[AutolockServiceTableCell alloc] initWithFrame: controlPos];    
			[servicesArray addObject:Autolock];
			
		}
		
		//--------------------------------------------SettingsArray--------------------------------------------
		
		
		/* Holds the services that are listed under the Network Services group */    
		settingsArray = [[[NSMutableArray alloc] init] retain];
		
		/* Initialize the Edge Service Control */
		EDGE2 = [[EDGEServiceTableCell2 alloc] initWithFrame: controlPos];	
		/* Add this to the array of services */
		[settingsArray addObject:EDGE2];
		
		
		/* Initialize the Bluetooth Control */
		Bluetooth2 = [[BluetoothServiceTableCell2 alloc] initWithFrame: controlPos];
		/* Add this to the array of services */
		[settingsArray addObject:Bluetooth2];
		
		
		/* Initialize the Wifi Control */
		Wifi2 = [[WifiServiceTableCell2 alloc] initWithFrame: controlPos];
		/* Add this to the array of services */
		[settingsArray addObject:Wifi2];
		
		/* Initialize the Airport Control */
		Airplane2 = [[PhoneServiceTableCell2 alloc] initWithFrame: controlPos];
		/* Add this to the array of services */
		[settingsArray addObject:Airplane2];
		
		/* Initialize the OpenSSH Control */    
		/* Add this to the array of services, only if the opensshd daemon exists */
		if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.openssh.sshd.plist"]) {
			SSH2 = [[SSHServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:SSH2];
		}
		
		
		/* Initialize the Dropbear SSH Control */
		Dropbear2 = nil;
		NSString *dropbear = @"/System/Library/LaunchDaemons/au.asn.ucc.matt.dropbear.plist";
		if ([fileManager fileExistsAtPath:dropbear]) {
			Dropbear2 = [[SSHServiceTableCell2 alloc] initWithFrame: controlPos];
		} else if ([fileManager fileExistsAtPath:(dropbear = @"/Library/LaunchDaemons/au.asn.ucc.matt.dropbear.plist")]) {
			Dropbear2 = [[SSHServiceTableCell2 alloc] initWithFrame: controlPos];
		}
		
		/* Add this to the array of services, only if the sshd daemon exists */
		if (Dropbear2 != nil) {
			[settingsArray addObject:Dropbear2];
		}
		
		
		/* Initialize the AFP Control */    
		/* Add this to the array of services, only if the AFP daemon exists */
		if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.core.afp.plist"]) {
			AFP2 = [[AFPServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:AFP2];
		}
		
		
		/* Initialize the Samba Control */    
		/* Add this to the array of services, only if the Samba daemon exists */
		if ([fileManager fileExistsAtPath:@"/usr/local/samba/smbd"]) {
			Samba2 = [[SambaServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:Samba2];
		}
		
		
		/* Initialize the FireFly Control */    
		/* Add this to the array of services, only if the Firefly daemon exists */
		if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/org.fireflymediaserver.mt-daapd.plist"]) {
			Firefly2 = [[FireflyServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:Firefly2];
		}
		
		
		/* Initialize the Apache Control */    
		/* Add this to the array of services, only if the Apache daemon exists */
		if ([fileManager fileExistsAtPath:@"/System/Library/LaunchDaemons/org.apache.httpd.plist"]) {
			Apache2 = [[ApacheServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:Apache2];
		}
		
		
		/* Initialize the iSpit Control */    
		/* Add this to the array of services, only if the iSpit daemon exists */
		if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/nl.robota.iphone.ispit.plist"]) {
			iSpit2 = [[iSpitServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:iSpit2];
		}
		
		
		/* Initialize the Lighttpd Control */    
		/* Add this to the array of services, only if the Lighttpd daemon exists */
		if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.amcgregor.lighttpd.plist"]) {
			Lighttpd2 = [[LighttpdServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:Lighttpd2];
		}
		
		/* Initialize the Filemshare Control */    
		/* Add this to the array of services, only if the fileshare daemon exists */
		if ([fileManager fileExistsAtPath:@"/System/Library/Internet Plug-Ins/File Download Plugin.webplugin/Info.plist"]) {
			Fileshare2 = [[FileShareServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:Fileshare2];
		}
		
		
		if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/com.sadun.autosnap"]) {
			Autosnap2 = [[ASnapServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:Autosnap2];
		}
		
		
		/* Initialize the Socks Server Control */    
		/* Add this to the array of services, only if the Socks Server daemon exists */
		if ([fileManager fileExistsAtPath:@"/Library/LaunchDaemons/net.sourceforge.socks-relay.srelay.plist"]) {
			Socks2 = [[SocksServiceTableCell2 alloc] initWithFrame: controlPos];
			[settingsArray addObject:Socks2];
		}
		
		
		/* Initialize the Tinyproxy  Control */    
		/* Add this to the array of services, only if the Tinyproxy daemon exists */
		Tinyproxy2 = nil;
		NSString *tinyproxy = @"/System/Library/LaunchDaemons/com.wickedpsyched.iphone.tinyproxy.plist";
		if ([fileManager fileExistsAtPath:tinyproxy]) {
			Tinyproxy2 = [[TinyproxyServiceTableCell2 alloc] initWithFrame: controlPos];
		} else if ([fileManager fileExistsAtPath:@"/System/Library/LaunchDaemonscom.wickedpsyched.iphone.tinyproxy.plist"]) {
			Tinyproxy2 = [[TinyproxyServiceTableCell2 alloc] initWithFrame: controlPos];
		}
		if (Tinyproxy2 != nil) {
			[settingsArray addObject:Tinyproxy2];
		}
		
		/* Initialize the IP Control  Add this to the array of services */
		IP2 = [[IPTableCell2 alloc] initWithFrame: controlPos];    
		[settingsArray addObject:IP2];
		
		
		/* Initialize the Autolock Control  Add this to the array of services */
		Autolock2 = [[AutolockServiceTableCell2 alloc] initWithFrame: controlPos];    
		[settingsArray addObject:Autolock2];
		
		//-----------------------------------------------------------------------------------------------------------------------
		
		
				/*set the array*/
		reloadArray = [servicesArray mutableCopy];

		topBar  = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 40.0f)];
		[topBar pushNavigationItem: [[UINavigationItem alloc] initWithTitle: @"NetServices"]];
		[topBar showButtonsWithLeftTitle:nil rightTitle:nil leftBack:nil];
		[topBar enableAnimation];
		[topBar setDelegate:self];
		[topBar setBarStyle: 1];
		
		/* Create the cells for the about information */
		aboutVersion = [[UIPreferencesTableCell alloc] init];
		[aboutVersion setTitle:[[NSString alloc] initWithFormat:@"Version %@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]];
		[aboutVersion _setDrawAsLabel: YES];
		[aboutVersion setDrawsBackground: NO];
		aboutCopyright = [[UIPreferencesTableCell alloc] init];
		[aboutCopyright setTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleCopyright"]];
		[aboutCopyright _setDrawAsLabel: YES];
		[aboutCopyright setDrawsBackground: NO];
		

				/* Populate the Preference table */
		[pref reloadData];
		
		/*Set the views*/
		[testview1 addSubview:topBar];
		[testview1 addSubview:pref];
		[testview2 addSubview:pref2];
	

		
		

		
		
		// _transitionView is used for handling transitions of the views only
		// _barTransitionView is used to handle the button bars transitioning
		_transitionView = [ self createTransitionView ];
		_barTransitionView = [ self createBarTransitionView ];
		_buttonBar = [ self createButtonBar ];
		
		[ self addSubview: _transitionView ];
		[ self addSubview: _barTransitionView ];
		
		[ _transitionView transition:6 toView:testview1 ];
		[ _barTransitionView transition:6 toView:_buttonBar ];			
		
		
	}
	return self;
}

- (UITransitionView *)createTransitionView {
	UITransitionView *transitionView = [ [ UITransitionView alloc ] initWithFrame:CGRectMake(0,0,320,460)];
    return transitionView;
}

- (UITransitionView *)createBarTransitionView {
	UITransitionView *transitionBarView = [ [ UITransitionView alloc ] initWithFrame:CGRectMake(0.0f, 419.0f, 320.0f, 49.0f)];
	// Create empty(blank) view for to transition the button bar to
	blankView = [ [ UIView alloc ] initWithFrame:CGRectMake(0.0f, 419.0f, 320.0f, 49.0f)];
	
	return transitionBarView;
}




- (UIButtonBar *)createButtonBar {
    UIButtonBar *buttonBar;
    buttonBar = [ [ UIButtonBar alloc ] 
       initInView: self
		withFrame: CGRectMake(0.0f, 0.0f, 320.0f, 49.0f)
	 withItemList: [ self buttonBarItems ] ];
    [buttonBar setDelegate:self];
    [buttonBar setBarStyle:1];
    [buttonBar setButtonBarTrackingMode: 2];
	
    int buttons[5] = { 1, 2, 3, 4, 5};
    [buttonBar registerButtonGroup:0 withButtons:buttons withCount: 5];
    [buttonBar showButtonGroup: 0 withDuration: 0.0f];
    int tag;
	
    for(tag = 1; tag < 6; tag++) {
        [ [ buttonBar viewWithTag:tag ] 
            setFrame:CGRectMake(2.0f + ((tag - 1) * 64.0f), 3.0f, 60.0f, 36.0f)
			];
    }
    [ buttonBar showSelectionForButton: 1];
	
    return buttonBar;
}

- (NSArray *)buttonBarItems {
    return [ NSArray arrayWithObjects:
        [ NSDictionary dictionaryWithObjectsAndKeys:
							  @"buttonBarItemTapped:", kUIButtonBarButtonAction,
			@"buttonSettings.png", kUIButtonBarButtonInfo,
			@"buttonSettings.png", kUIButtonBarButtonSelectedInfo,
			[ NSNumber numberWithInt: 1], kUIButtonBarButtonTag,
            self, kUIButtonBarButtonTarget,
			@"Services", kUIButtonBarButtonTitle,
			@"0", kUIButtonBarButtonType,
			nil 
			],
		
        [ NSDictionary dictionaryWithObjectsAndKeys:
							  @"buttonBarItemTapped:", kUIButtonBarButtonAction,
			@"buttonSettings.png", kUIButtonBarButtonInfo,
			@"buttonSettings.png", kUIButtonBarButtonSelectedInfo,
			[ NSNumber numberWithInt: 2], kUIButtonBarButtonTag,
            self, kUIButtonBarButtonTarget,
			@"Settings", kUIButtonBarButtonTitle,
			@"0", kUIButtonBarButtonType,
			nil 
			], 
		
		[ NSDictionary dictionaryWithObjectsAndKeys:
							  @"buttonBarItemTapped:", kUIButtonBarButtonAction,
			@"imageup.png", kUIButtonBarButtonInfo,
			@"imagedown.png", kUIButtonBarButtonSelectedInfo,
			[ NSNumber numberWithInt: 3], kUIButtonBarButtonTag,
            self, kUIButtonBarButtonTarget,
			@"Button3", kUIButtonBarButtonTitle,
			@"0", kUIButtonBarButtonType,
			nil
			],
		
		[ NSDictionary dictionaryWithObjectsAndKeys:
							  @"buttonBarItemTapped:", kUIButtonBarButtonAction,
			@"imageup.png", kUIButtonBarButtonInfo,
			@"imagedown.png", kUIButtonBarButtonSelectedInfo,
			[ NSNumber numberWithInt: 4], kUIButtonBarButtonTag,
            self, kUIButtonBarButtonTarget,
			@"Button4", kUIButtonBarButtonTitle,
			@"0", kUIButtonBarButtonType,
			nil
			],
		
        [ NSDictionary dictionaryWithObjectsAndKeys:
							  @"buttonBarItemTapped:", kUIButtonBarButtonAction,
			@"imageup.png", kUIButtonBarButtonInfo,
			@"imagedown.png", kUIButtonBarButtonSelectedInfo,
			[ NSNumber numberWithInt: 5], kUIButtonBarButtonTag,
            self, kUIButtonBarButtonTarget,
			@"Button5", kUIButtonBarButtonTitle,
			@"0", kUIButtonBarButtonType,
			nil
			], 
		
        nil
		];
}

- (void)buttonBarItemTapped:(id) sender {
    int button = [ sender tag ];
    switch (button) {
        case 1:
			if (currentView == CB_1) { }
			else {
				[self testAnimation];
				[ _transitionView transition:0 toView:testview1 ];
				currentView = CB_1;
				reloadArray =  [servicesArray mutableCopy];
				[pref reloadData];
			}
            break;
        case 2:
			if (currentView == CB_2) { }
			else {
				[self testAnimation];
				[ _transitionView transition:0 toView:testview2 ];
				currentView = CB_2;
				reloadArray = [settingsArray mutableCopy];
				[pref reloadData];

			}
			break;
        case 3:
			if (currentView ==CB_3) { }
			else {
				[self testAnimation];
				[ _transitionView transition:0 toView:testview3 ];
				currentView = CB_3;
			}
			break;
        case 4:
			if (currentView == CB_4) { }
			else {
				[self testAnimation];
				[ _transitionView transition:0 toView:testview4 ];
				currentView = CB_4;
			}
			break;
		case 5:
			if (currentView == CB_5) { }
			else {
				[self testAnimation];
				[ _transitionView transition:0 toView:testview5 ];
				currentView = CB_5;
			}
			break;
    }
    
}


- (void)reloadButtonBar {
    [ _buttonBar removeFromSuperview ];
    [ _buttonBar release ];
    _buttonBar = [ self createButtonBar ];
}





// Sample layerkit animation
-(void)testAnimation {
	LKAnimation *animation = [LKTransition animation];
	[animation setType: @"oglFlip"];
	[animation setTimingFunction: [LKTimingFunction functionWithName: @"easeInEaseOut"]];
	[animation setFillMode: @"extended"];
	[animation setTransitionFlags: 3];
	[animation setDuration: 10];
	[animation setSpeed:0.35];
	[animation setSubtype: @"fromLeft"];
	[[self _layer] addAnimation: animation forKey: 0];
}

/**
* Called by the preference table to determine how many separate groups there are  
 **/
- (int)numberOfGroupsInPreferencesTable:(UIPreferencesTable *)pref2 {
	return 2;
}

/**
* Called by the preference table to setup how many unique rows are in each group
 **/
- (int)preferencesTable:(UIPreferencesTable *)pref2 numberOfRowsInGroup:(int)group {
	switch (group) {
		case 0:
			return [settingsArray count];
		case 1:
			return 2;
	}
}

- (UIPreferencesTableCell *)preferencesTable:(UIPreferencesTable *)pref2 cellForGroup:(int)group {
	if (groupcell[group] == NULL) {
		groupcell[group] = [[UIPreferencesTableCell alloc] init];
	}
	
	return groupcell[group];
}

- (float)preferencesTable:(UIPreferencesTable *)pref2 heightForRow:(int)row inGroup:(int)group withProposedHeight:(float)proposed {
	switch (group) {
		case 0:
			return proposed;
		case 1:
			return 0.5*proposed;
		default:
			return 2*proposed;
	}
}

- (BOOL)preferencesTable:(UIPreferencesTable *)pref2 isLabelGroup:(int)group {
	return NO;
}

- (UIPreferencesTableCell *)preferencesTable:(UIPreferencesTable *)pref2 cellForRow:(int)row inGroup:(int)group {
	switch(group) {
		case 0:
			return [settingsArray objectAtIndex:row];
		case 1:
			switch(row) {
				case 0:
					return aboutVersion;
				case 1:
					return aboutCopyright;
			}
	}
}

/*--------------------------------------------------------------------------------------------------------------*/

- (int)preferencesTable:(UIPreferencesTable *)pref numberOfRowsInGroup:(int)group {
	switch (group) {
		case 0:
			return [reloadArray count];
		case 1:
			return 1;
		case 2:
			return 2;
	}
}

- (UIPreferencesTableCell *)preferencesTable:(UIPreferencesTable *)pref cellForGroup:(int)group {
	if (groupcell[group] == NULL) {
		groupcell[group] = [[UIPreferencesTableCell alloc] init];
	}
	
	return groupcell[group];
}

- (float)preferencesTable:(UIPreferencesTable *)pref heightForRow:(int)row inGroup:(int)group withProposedHeight:(float)proposed {
	switch (group) {
		case 0:
			return proposed;
		case 1:
			return proposed;
		case 2:
			return 0.5*proposed;
		default:
			return 2*proposed;
	}
}

- (BOOL)preferencesTable:(UIPreferencesTable *)pref isLabelGroup:(int)group {
	return NO;
}

- (UIPreferencesTableCell *)preferencesTable:(UIPreferencesTable *)pref cellForRow:(int)row inGroup:(int)group {
	switch(group) {
		case 0:
			return [reloadArray objectAtIndex:row];
			NSLog(@"reloadArray:%@ -", reloadArray);
		case 1:
			return netServicesHeader;
		case 2:
			switch(row) {
				case 0:
					return aboutVersion;
				case 1:
					return aboutCopyright;
			}
	}
}

-(void)navigationBar:(UINavigationBar*)bar buttonClicked:(int)button{
	NSLog(@"navbar clicked bar:%@ button:%i", bar, button);
	if (button == 0){
		
	}
	if (button == 1){
		system([[NSString stringWithFormat:@"/Applications/NetServices.app/ProgramFiles/bin/pkill NetServices"] UTF8String]);
	}
}

- (void)applicationWillTerminate {
	[netServicesHeader release];
	
	[aboutVersion release];
	[aboutCopyright release];
	
	for (int i = 0; i < GROUPS; i++)
		[groupcell[i] release];
	
	for(int i = 0; i < [reloadArray count]; i++) {
		[[reloadArray objectAtIndex:i] release];
		[[reloadArray objectAtIndex:i] release];
		
	}
	[reloadArray release];
	
	for(int i = 0; i < [settingsArray count]; i++) {
		[[settingsArray objectAtIndex:i] release];
		[[settingsArray objectAtIndex:i] release];
		
	}
	[settingsArray release];
	
	
	for(int i = 0; i < [servicesArray count]; i++) {
		[[servicesArray objectAtIndex:i] release];
		[[servicesArray objectAtIndex:i] release];
		
	}
	[servicesArray release];
}

@end //@implementation ButtonBarView