diff --git a/Classes/MGMController.h b/Classes/MGMController.h index b137a6d..a35fafd 100644 --- a/Classes/MGMController.h +++ b/Classes/MGMController.h @@ -19,6 +19,8 @@ extern NSString * const MGMNIcon; extern NSString * const MGMNSound; extern NSString * const MGMNTask; +@protocol NSWindowDelegate; + @interface MGMController : NSObject { NSWindow *instructions; diff --git a/Classes/MGMController.m b/Classes/MGMController.m index a7a00b5..a501cb3 100644 --- a/Classes/MGMController.m +++ b/Classes/MGMController.m @@ -43,7 +43,7 @@ NSString * const MGMVersion = @"MGMVersion"; NSString * const MGMLaunchCount = @"MGMLaunchCount"; NSString * const MGMApplicationSupportPath = @"~/Library/Application Support/MrGeckosMedia/SoundNote/"; -NSString * const MGMNotesName = @"notes.txt"; +NSString * const MGMNotesName = @"notes.rtf"; NSString * const MGMGrowlName = @"growl.plist"; NSString * const MGMDisabledName = @"disabled.plist"; NSString * const MGMSoundEndedNotification = @"MGMSoundEndedNotification"; @@ -103,15 +103,15 @@ static MGMController *MGMSharedController; NSFileManager *manager = [NSFileManager defaultManager]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if ([defaults objectForKey:MGMVersion]==nil) { + if ([defaults objectForKey:MGMVersion]==nil || [[defaults objectForKey:MGMVersion] isEqual:@"0.2"]) { if ([manager fileExistsAtPath:[MGMApplicationSupportPath stringByExpandingTildeInPath]]) { [manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMNotesName stringByDeletingPathExtension] ofType:[MGMNotesName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMNotesName]]; [manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMGrowlName stringByDeletingPathExtension] ofType:[MGMGrowlName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMGrowlName]]; [manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMDisabledName stringByDeletingPathExtension] ofType:[MGMDisabledName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMDisabledName]]; [manager removeItemAtPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:@"note.txt"]]; [self showInstructions]; - [defaults setObject:[[MGMSystemInfo info] applicationVersion] forKey:MGMVersion]; } + [defaults setObject:[[MGMSystemInfo info] applicationVersion] forKey:MGMVersion]; } [self registerDefaults]; if (![manager fileExistsAtPath:[MGMApplicationSupportPath stringByExpandingTildeInPath]]) { diff --git a/Classes/MGMSound.h b/Classes/MGMSound.h index 72ec05c..2fef453 100644 --- a/Classes/MGMSound.h +++ b/Classes/MGMSound.h @@ -19,6 +19,8 @@ - (void)soundDidFinishPlaying:(MGMSound *)theSound; @end +@protocol NSSoundDelegate; + @interface MGMSound : NSObject #if TARGET_OS_IPHONE diff --git a/Classes/Watchers/MGMAccessibleWatcher.m b/Classes/Watchers/MGMAccessibleWatcher.m index e23daf9..3189739 100644 --- a/Classes/Watchers/MGMAccessibleWatcher.m +++ b/Classes/Watchers/MGMAccessibleWatcher.m @@ -88,8 +88,8 @@ static void receivedNotification(AXObserverRef observer, AXUIElementRef element, [self observe:kAXMenuOpenedNotification element:element observer:observer application:theApplication]; [self observe:kAXMenuClosedNotification element:element observer:observer application:theApplication]; [self observe:kAXMenuItemSelectedNotification element:element observer:observer application:theApplication]; - [self observe:kAXRowExpandedNotification element:element observer:observer application:theApplication]; - [self observe:kAXRowCollapsedNotification element:element observer:observer application:theApplication]; + [self observe:CFSTR("AXRowExpanded") element:element observer:observer application:theApplication]; + [self observe:CFSTR("AXRowCollapsed") element:element observer:observer application:theApplication]; [self observe:kAXSelectedRowsChangedNotification element:element observer:observer application:theApplication]; if (![[MGMSystemInfo info] isAfterSnowLeopard]) { [self observe:kAXApplicationHiddenNotification element:element observer:observer application:theApplication]; @@ -145,9 +145,9 @@ static void receivedNotification(AXObserverRef observer, AXUIElementRef element, [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"menuitemselected", MGMNName, @"Menu Item Selected", MGMNTitle, [NSString stringWithFormat:@"%@ in %@", (NSString *)title, [information objectForKey:(NSString *)kCFBundleNameKey]], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; if (title!=NULL) CFRelease(title); - } else if ([theName isEqual:(NSString *)kAXRowExpandedNotification]) { + } else if ([theName isEqual:@"AXRowExpanded"]) { [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"rowexpanded", MGMNName, @"Row Expanded", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; - } else if ([theName isEqual:(NSString *)kAXRowCollapsedNotification]) { + } else if ([theName isEqual:@"AXRowCollapsed"]) { [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"rowcollapsed", MGMNName, @"Row Collapsed", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; } else if ([theName isEqual:(NSString *)kAXSelectedRowsChangedNotification]) { [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"selectedrowschanged", MGMNName, @"Selected Rows Changed", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; diff --git a/Classes/Watchers/MGMApplicationWatcher.m b/Classes/Watchers/MGMApplicationWatcher.m index 6eee573..c2abf3e 100644 --- a/Classes/Watchers/MGMApplicationWatcher.m +++ b/Classes/Watchers/MGMApplicationWatcher.m @@ -27,6 +27,8 @@ OSStatus frontAppChanged(EventHandlerCallRef nextHandler, EventRef theEvent, voi return (CallNextEventHandler(nextHandler, theEvent)); } +@class NSRunningApplication; + @implementation MGMApplicationWatcher - (id)init { if ((self = [super init])) { diff --git a/Classes/Watchers/MGMFireWireWatcher.m b/Classes/Watchers/MGMFireWireWatcher.m index a1c646a..8d511b3 100644 --- a/Classes/Watchers/MGMFireWireWatcher.m +++ b/Classes/Watchers/MGMFireWireWatcher.m @@ -49,17 +49,6 @@ static NSString *nameForIOFW(io_object_t object) { return @"Unnamed Device"; } -static NSString *idForIOFW(io_object_t object) { - uint64_t ioDeviceID; - NSString *deviceID = nil; - kern_return_t result = IORegistryEntryGetRegistryEntryID(object, &ioDeviceID); - if (result==noErr) - deviceID = [NSString stringWithFormat:@"%11x", ioDeviceID]; - if (deviceID!=nil) - return deviceID; - - return @"Unknown ID"; -} @implementation MGMFireWireWatcher - (id)init { @@ -77,9 +66,9 @@ static NSString *idForIOFW(io_object_t object) { NSLog(@"Unable to register for firewire add %d", result); io_object_t object; while ((object = IOIteratorNext(found))) { - NSString *deviceID = idForIOFW(object); - if (![firewireDevices containsObject:deviceID]) - [firewireDevices addObject:deviceID]; + NSString *deviceName = nameForIOFW(object); + if (![firewireDevices containsObject:deviceName]) + [firewireDevices addObject:deviceName]; IOObjectRelease(object); } @@ -89,9 +78,9 @@ static NSString *idForIOFW(io_object_t object) { NSLog(@"Unable to register for firewire remove %d", result); else { while ((object = IOIteratorNext(found))) { - NSString *deviceID = idForIOFW(object); - if ([firewireDevices containsObject:deviceID]) - [firewireDevices removeObject:deviceID]; + NSString *deviceName = nameForIOFW(object); + if ([firewireDevices containsObject:deviceName]) + [firewireDevices removeObject:deviceName]; IOObjectRelease(object); } } @@ -108,17 +97,17 @@ static NSString *idForIOFW(io_object_t object) { } - (void)firewireDeviceConnected:(io_object_t)theDevice { - NSString *deviceID = idForIOFW(theDevice); - if (![firewireDevices containsObject:deviceID]) { - [firewireDevices addObject:deviceID]; - [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewireconnected", MGMNName, @"FireWire Connected", MGMNTitle, nameForIOFW(theDevice), MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]]; + NSString *deviceName = nameForIOFW(theDevice); + if (![firewireDevices containsObject:deviceName]) { + [firewireDevices addObject:deviceName]; + [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewireconnected", MGMNName, @"FireWire Connected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]]; } } - (void)firewireDeviceDisconnected:(io_object_t)theDevice { - NSString *deviceID = idForIOFW(theDevice); - if ([firewireDevices containsObject:deviceID]) { - [firewireDevices removeObject:deviceID]; - [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewiredisconnected", MGMNName, @"FireWire Disconnected", MGMNTitle, nameForIOFW(theDevice), MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]]; + NSString *deviceName = nameForIOFW(theDevice); + if ([firewireDevices containsObject:deviceName]) { + [firewireDevices removeObject:deviceName]; + [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewiredisconnected", MGMNName, @"FireWire Disconnected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]]; } } @end \ No newline at end of file diff --git a/Classes/Watchers/MGMUSBWatcher.m b/Classes/Watchers/MGMUSBWatcher.m index 7f89df4..a92f333 100644 --- a/Classes/Watchers/MGMUSBWatcher.m +++ b/Classes/Watchers/MGMUSBWatcher.m @@ -38,17 +38,6 @@ static NSString *nameForIOUSB(io_object_t object) { return @"Unnamed Device"; } -static NSString *idForIOUSB(io_object_t object) { - uint64_t ioDeviceID; - NSString *deviceID = nil; - kern_return_t result = IORegistryEntryGetRegistryEntryID(object, &ioDeviceID); - if (result==noErr) - deviceID = [NSString stringWithFormat:@"%11x", ioDeviceID]; - if (deviceID!=nil) - return deviceID; - - return @"Unknown ID"; -} @implementation MGMUSBWatcher - (id)init { @@ -66,9 +55,9 @@ static NSString *idForIOUSB(io_object_t object) { NSLog(@"Unable to register for usb add %d", result); io_object_t object; while ((object = IOIteratorNext(found))) { - NSString *deviceID = idForIOUSB(object); - if (![USBDevices containsObject:deviceID]) - [USBDevices addObject:deviceID]; + NSString *deviceName = nameForIOUSB(object); + if (![USBDevices containsObject:deviceName]) + [USBDevices addObject:deviceName]; IOObjectRelease(object); } @@ -78,9 +67,9 @@ static NSString *idForIOUSB(io_object_t object) { NSLog(@"Unable to register for usb remove %d", result); else { while ((object = IOIteratorNext(found))) { - NSString *deviceID = idForIOUSB(object); - if ([USBDevices containsObject:deviceID]) - [USBDevices removeObject:deviceID]; + NSString *deviceName = nameForIOUSB(object); + if ([USBDevices containsObject:deviceName]) + [USBDevices removeObject:deviceName]; IOObjectRelease(object); } } @@ -97,17 +86,17 @@ static NSString *idForIOUSB(io_object_t object) { } - (void)usbDeviceConnected:(io_object_t)theDevice { - NSString *deviceID = idForIOUSB(theDevice); - if (![USBDevices containsObject:deviceID]) { - [USBDevices addObject:deviceID]; - [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbconnected", MGMNName, @"USB Connected", MGMNTitle, nameForIOUSB(theDevice), MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]]; + NSString *deviceName = nameForIOUSB(theDevice); + if (![USBDevices containsObject:deviceName]) { + [USBDevices addObject:deviceName]; + [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbconnected", MGMNName, @"USB Connected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]]; } } - (void)usbDeviceDisconnected:(io_object_t)theDevice { - NSString *deviceID = idForIOUSB(theDevice); - if ([USBDevices containsObject:deviceID]) { - [USBDevices removeObject:deviceID]; - [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbdisconnected", MGMNName, @"USB Disconnected", MGMNTitle, nameForIOUSB(theDevice), MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]]; + NSString *deviceName = nameForIOUSB(theDevice); + if ([USBDevices containsObject:deviceName]) { + [USBDevices removeObject:deviceName]; + [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbdisconnected", MGMNName, @"USB Disconnected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]]; } } @end \ No newline at end of file diff --git a/Resources/Info.plist b/Resources/Info.plist index c9c7f74..19bac00 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -19,13 +19,15 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.2 + 0.2.1 CFBundleSignature ???? CFBundleURLTypes CFBundleVersion - 0.2 + 0.2.1 + LSApplicationCategoryType + public.app-category.utilities LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} LSUIElement @@ -60,8 +62,6 @@ dsa_pub.pem SUScheduledCheckInterval 86400 - LSApplicationCategoryType - public.app-category.utilities UTExportedTypeDeclarations UTImportedTypeDeclarations diff --git a/SoundNote.xcodeproj/project.pbxproj b/SoundNote.xcodeproj/project.pbxproj index dca6521..73acf9d 100644 --- a/SoundNote.xcodeproj/project.pbxproj +++ b/SoundNote.xcodeproj/project.pbxproj @@ -179,8 +179,8 @@ buildActionMask = 2147483647; files = ( 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, - 2A34E62611E237380032F02E /* IOKit.framework in Frameworks */, 2A34E68911E241CA0032F02E /* SystemConfiguration.framework in Frameworks */, + 2A34E62611E237380032F02E /* IOKit.framework in Frameworks */, 2A34E7DC11E276C80032F02E /* IOBluetooth.framework in Frameworks */, 2A34E89E11E286500032F02E /* GeckoReporter.framework in Frameworks */, 2A34E89F11E286500032F02E /* Sparkle.framework in Frameworks */, @@ -514,6 +514,7 @@ INSTALL_PATH = "$(HOME)/Applications"; "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; PRODUCT_NAME = SoundNote; + SDKROOT = macosx10.6; }; name = Debug; }; @@ -533,6 +534,7 @@ INSTALL_PATH = "$(HOME)/Applications"; "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; PRODUCT_NAME = SoundNote; + SDKROOT = macosx10.6; }; name = Release; };