All pastes #217614 Raw Edit

Something

public text v1 · immutable
#217614 ·published 2006-10-23 18:46 UTC
rendered paste body
#import <AppKit/AppKit.h>
#import "appControl.h"
#import "customSlider.h"
#import <DiscRecording/DiscRecording.h>
#import <DiscRecordingUI/DiscRecordingUI.h>
#import <Foundation/Foundation.h>
#import <Foundation/NSBundle.h>
#import <QuickTime/QuickTime.h>
#import <QTKit/QTKit.h>
#import <QTKit/QTMovieView.h>

#import "mediaEngine.h"

// Diego Massanti
// Media Pack for Mac 0.3 Alpha
// (c) 2006 by ReverseMedia GmBH.
// This code (c) by Diego Massanti // Portions by Apple Computer where noted.



@implementation appControl



- (NSString*)queryPlist:(NSString*)key
{
	NSString *keyValue;
	NSString *path= @"/System/Library/CoreServices/SystemVersion.plist"; 
	NSString *errorString;
	NSData *xmlData;
	
	
	id plist;
	
	xmlData = [NSData dataWithContentsOfFile:path];
	plist = (id)CFPropertyListCreateFromXMLData(kCFAllocatorDefault,
												(CFDataRef)xmlData, kCFPropertyListMutableContainers,
												(CFStringRef *)&errorString);
	keyValue = [plist valueForKey:key];
	return keyValue;
}

- (NSArray*)createLayoutForBurn:(NSArray*)list
{
	unsigned i, count = [list count];
	NSMutableArray  *tracks = [NSMutableArray arrayWithCapacity:count];
	for (i=0; i<count; ++i)
	{
		NSString    *path = [list objectAtIndex:i];
		NSLog(path);
		
		// HERE I CREATE THE TRACK.
		// REMEMBER THE LOGICS YOU FOOL! 12-8-06

		DRTrack      *track = [DRTrack trackForAudioFile:path];
		NSLog(path);
		DRTrack		 *trackLog = [DRTrack trackForAudioFile:path];
		if (track == nil)
		{
			NSLog(@"An error occurred at track %d: %@", (i+1), path);
			[NSException raise:NSObjectNotAvailableException
						format:@"Source file for track %u was not found, or could not be imported!  Filename was %@",
				(i+1), path];
		}
		
		NSMutableDictionary	*trackProperties = [[track properties] mutableCopy];
		[track setProperties:trackProperties];
		
		//OBJECT INSTANCE
		[tracks addObject:track];
		NSLog([[trackLog properties] description]);
	}
	return tracks;
}




// Custom function "Critic Alert" for managing exceptions and alerts.
static void criticAlert(NSString* message) {
	NSAlert* alrt = [NSAlert alertWithMessageText:@"Unexpected error..."
									defaultButton:@"Ok" alternateButton:nil otherButton:nil informativeTextWithFormat:message];
	[alrt setAlertStyle:NSCriticalAlertStyle];
	[alrt runModal];
}


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
{
	[[NSApp mainWindow] center];;
	
	
/*
	NSString* ProductVersion= [self queryPlist:@"ProductVersion"];
	NSLog(ProductVersion);
	if ([ProductVersion isEqualToString:@"10.4.6"])
	{
		criticAlert(@"There is a well known bug in Mac OS X 10.4.6 that prevents the burning engine to write your CD. We detected that you are running this OS version, please update your system. Application will close.");
		[NSApp terminate:self];
	}*/
	[mediaEngine initialization];

	
}
/*- (IBAction)burn:(id)sender
{	
	DRBurnSetupPanel*	bsp = [DRBurnSetupPanel setupPanel];
	//Here i create a layout image with layoutForImageFIle ** DOCUMENTATION FOR THIS ONLY IN THE RELEASE NOTES FOR XCODE 2.3!!! ** Damn Apple!
	NSString*			cueFile = [[NSBundle mainBundle] pathForResource:@"massanti" ofType:@"cue"];
	
	////////////////////-----------------------------///////////////////////////////
	DRBurn*				drb = [DRBurn layoutForImageFile:cueFile];
	
	
	[bsp setCanSelectTestBurn:YES];
	[bsp setDelegate:self];
	
	
	if ([bsp runSetupPanel] == NSOKButton)
	{
		
		DRBurnProgressPanel*	bpp = [DRBurnProgressPanel progressPanel];
		
		[bpp setDelegate:self];
		// HERE I MUST REMEMBER TO ADD THE IMAGE HANDLING ROUTINE. LATER
		@try 
		{
			
			[bpp beginProgressSheetForBurn:[bsp burnObject] layout:drb modalForWindow:[NSApp mainWindow]];
		}
		@catch (NSException *exception)
		{
			NSLog(@"main: Caught %@: %@", [exception name], [exception  reason]);
			NSString*	errorTxt = ([exception  reason]);
			criticAlert(errorTxt);
		}
	}
	
}*/


- (IBAction)burn:(id)sender
{
	[NSApp beginSheet:burnTypeDialog
	   modalForWindow:[NSApp mainWindow]
		modalDelegate:nil
	   didEndSelector:nil
		  contextInfo:nil];
	
}

- (IBAction)burnCancel:(id)sender
{	
	[NSApp endSheet:burnTypeDialog];
	[burnTypeDialog orderOut:self];	
}

- (IBAction)burnAudioCD:(id)sender
{	
	[NSApp endSheet:burnTypeDialog];
	[burnTypeDialog orderOut:self];
	
	DRBurnSetupPanel*	bsp = [DRBurnSetupPanel setupPanel];
	[bsp setCanSelectTestBurn:YES]; 
	[bsp beginSetupSheetForWindow:[NSApp mainWindow]
		modalDelegate:self
		didEndSelector:@selector(burnSetupPanelDidEnd:returnCode:contextInfo:)
			contextInfo:nil];
	
	
}
- (IBAction)burnBackup:(id)sender
{
	/// TO DO
}
- (void)burnSetupPanelDidEnd:(DRBurnSetupPanel*)panel returnCode:(int)returnCode contextInfo:(void*)contextInfo
{	
	[panel orderOut:self];
	NSArray*			trackList = [[NSBundle mainBundle] pathsForResourcesOfType:@"m4a" inDirectory:@""];
	NSArray*			drb = [self createLayoutForBurn:trackList];
		
	
	
	if (returnCode != NSOKButton) return;
	DRBurn				*burn = [panel burnObject];
	DRBurnProgressPanel*	bpp = [DRBurnProgressPanel progressPanel];
	[bpp setDelegate:self];
	[bpp setVerboseProgressStatus:YES];
	NSLog([[burn properties]description]); 
	[bpp beginProgressSheetForBurn:burn layout:drb modalForWindow:[NSApp mainWindow]];	
}


@end